All jQuery Codes

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 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 »

jQuery code to hide table rows with empty td element

Find jQuery code to hide those table rows (<tr>) which have at least one or more <td> element as empty or with no value. To hide table rows, iterate through all the td element and check it's text. If it is empty then hide it's parent (which is tr) using .hide(). Related Post: jQuery code […]
Read the rest of this entry »

jQuery code to highlight empty table element

Find jQuery code to highlight those <td> elements within a table/ Grid/ GridView/ DataGrid which have no value associated with it or which are empty. All is required is to loop through all the <td> element and check it's value. If it is empty, then assign background color to it so that it looks highlighted. […]
Read the rest of this entry »

Sort Dropdown list items using jQuery

In this post, find out jQuery code to sort dropdown list items. The items can be sorted by item's text or by item's value in ascending or descending order. Related Post: Common Dropdown operation using jQuery How to Reset DropDown using jQuery How to Disable DropDown List Item using jQuery To sort the items, use […]
Read the rest of this entry »

How to Change ID of DOM element using jQuery

In this short and quick post, find out how to change or reset ID of any HTML DOM element using jQuery. To Change/Reset element ID, just need to change the value of "id" attribute. Below jQuery code changes ID of "dvDemo" element to "dvDemoNew". $('#dvDemo').attr('id', 'dvDemoNew'); See result below See Complete Code Feel free to […]
Read the rest of this entry »

Responsive Menu
Add more content here...