Archive for November, 2012

Make jQuery contains selector case insensitive

jQuery has ":contains" selector which can be used to select all elements with specific text. But default behavior of contains selector is case sensitive. For ":contains" the word "jquery" and "jQuery" are different. Let's find out using a simple demo. Below jQuery code will hide all the "p" tag element which contains "jquery" as text. […]
Read the rest of this entry »

jQuery code to disable “Enter” key

Got a strange requirement from my client that whenever the "Enter" key is pressed on the page, the page should not be submitted. It should only be submitted when user clicks the submit button using mouse. Well, this was pretty simple and easy with jQuery. I have implemented it in 2 mins and thought of […]
Read the rest of this entry »

Truncate text/string using jQuery

Yesterday I need to truncate string and I was asking myself "How Can I Truncate A String In jQuery?". There are already many jQuery plugins available to truncate the text/string but there is an issue with these plugin. They actually limits the character length of the text, instead of fitting the text with respect to […]
Read the rest of this entry »

jQuery code to handle broken (not found) images in webpage

In this post, find out jQuery code to handle broken link images or not found images on a webpage. This can happen when path of the image is changed or it is removed or renamed. But this can be answered easily with jQuery. When the image is not loaded properly, use jQuery error event on […]
Read the rest of this entry »

jQuery UI DatePicker, IE 7 and an extra comma

Well, looking at the post title doesn't give you an idea about what the post is all about but that's best possible title I could think and come up with. "jQuery UI DatePicker, IE 7 and an extra comma" combination can give you some pain. Why? Let's see through a piece of code. Below jQuery […]
Read the rest of this entry »

jQuery code to find smallest div element

jQuery code to find smallest/shortest div element with respect to height of div element. The jQuery code iterates through all the div elements and finds the smallest and then highlight it. $(document).ready(function() { var allDivs = $('div'); var dvSmallest = allDivs[0]; $(allDivs).each(function() { if ($(this).height() < $(dvSmallest).height()) dvSmallest = $(this); }); $(dvSmallest).css('border', '2px solid red'); […]
Read the rest of this entry »

Responsive Menu
Add more content here...