All jQuery Tips

jQuery: Select all readonly input type textbox

In this short post, find jQuery code to select all readonly input type textboxes present on the page. $(function(){ $(":input[type=text][readonly='readonly']").val(""); }); However, if you have single readonly textbox element, then select it using its ID. And if you want to exclude all readonly input type textboxes from selection, then use below jQuery code. $(function(){ $(":input[type=text]:not([readonly='readonly'])").val(""); […]
Read the rest of this entry »

jQuery: How to Strip/Remove HTML tags

In this short post, find jQuery code to strip/remove HTML tags. To remove HTML tags, use text() function which returns only the text content and ignores the HTML portion. console.log($('#dvTest').text()); You can also strip/remove HTML tags from any variable as well as text() is jQuery function, so the variable needs to be converted into a […]
Read the rest of this entry »

Use protocol less URL for referencing jQuery

Learnt something new today and thought of sharing. Most of us, include the reference of jQuery library (if Google CDN is used) like this, http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js As you can see it is using HTTP protocol. The advantage of Google CDN files are cached up to one year which means that your users may not need to […]
Read the rest of this entry »

Ignored powerful shortcuts of jQuery

Many developers ignore shortcuts and power of jQuery and I myself being a victim of some of the useful, handy but yet ignored shortcuts of jQuery. These are not some advance or complex shortcuts but I guess these are used a lot. Consider, below jQuery code lines. $("#elm").css("display", "none"); //Line 1 $("#elm").css("display", ""); //Line 2 […]
Read the rest of this entry »

jQuery to redirect page after specific time interval

You must have come across any website which uses a webpage with some annoying advertisement and a message that says "You will be redirected to actual page after X seconds". This can be easily implemented with jQuery. In this post, find jQuery code to redirect user to another webpage after specific time interval or few […]
Read the rest of this entry »

Check for ‘#’ hash in URL using jQuery

In this short post, find jQuery code to check if URL contains "#" (hash) or not. This can be checked via location.hash property provided by JavaScript and same can be used in jQuery. $(document).ready(function(){ if(window.location.hash) { // # exists in URL } else { // No # in URL. } }); Feel free to contact […]
Read the rest of this entry »

Responsive Menu
Add more content here...