Abhineet.in

unlearning the learnt

Menu
  • Home
  • About
  • CAT Preparation
Menu

Tag: Javascript

Restrict number of selected checkboxes in html

Posted on June 29, 2022April 5, 2023 by Abhineet Mittal

This code will restrict html multi select input to given number. document.addEventListener( “click”, function( event ) { if ( event.target.matches( ‘.input-checkbox’ ) ) { var inputCheckboxes = document.querySelectorAll( ‘.input-checkbox[type=”checkbox”]:checked’ ); if( inputCheckboxes.length > 3 ) { event.preventDefault(); alert( ‘You cannot select more than 3 categories for a post.’ ); } } } );

Read more

Why click event not working on SVG

Posted on June 15, 2022April 5, 2023 by Abhineet Mittal

I created a simple menu with SVG icons and to my surprise, clicking on the icon was not taking me to the linked url. It turned out that as SVGs are independent HTML objects, the target element is actually nested path. So, it does not match with the clicked element and thus click event listeners…

Read more

Add event listener on SVG element

Posted on June 8, 2022April 5, 2023 by Abhineet Mittal

I was facing problem while adding event listener to an svg element. Then I added event listeners to both svg and path tags, and it worked.

Read more

Decode a PHP encoded string url in Javascript

Posted on January 17, 2021April 5, 2023 by Abhineet Mittal

Sometimes you may face a problem when you have to decode a string with Javascript which was originally url encoded with PHP. This can be an API response or cookie set by PHP setcookie function. A simple way to do this is through decodeURIComponent function in Javascript. But it leaves the "+" signs in the string….

Read more

Make Javascript sequential with “async” and “await”

Posted on April 11, 2020April 5, 2023 by Abhineet Mittal

Javascript code can be easily made sequential with the help of two simple, yet very powerful keywords “async” and “await”.

Read more

Categories

  • Business
  • CAT Preparation
  • Coding
  • Fiction
  • Finance
  • How-To-Life
  • Javascript
  • Life
  • Life at Infosys
  • Photoshop
  • Productivity
  • Publishing
  • Social Awareness
  • Startup
  • Technology
  • Uncategorized
  • Utilities
  • Visual Studio Code
  • Web Development
  • WordPress
  • Work Culture

Recent Posts

  • The Ultimate Guide to CAT Preparation: Tips and Tricks
  • Self-Publishing vs. Traditional Publishing: Which Is Right for You?
  • 7 Effective Strategies to Overcome Procrastination and Achieve Your Goals
  • How to detect English/ASCII string in PHP
  • The state of automobile dealerships in India

Recent Comments

  • Rohan George on Intermediate, Stream & Location: Luck by Chance
  • Ashika on Intermediate, Stream & Location: Luck by Chance
  • Steve on My first job, Infosys
  • SAKTHI on Finally, its Mysore…
  • Akash dhyani Akash on Training Begins…
© 2023 Abhineet.in | Powered by Minimalist Blog WordPress Theme