Posts Tagged ‘jquery’
Uses of Jquery Filter Selector
December 4, 2013
Leave a comment
Jquery Filter selector becomes very handy for a geek who’s found of lambda function in LINQ. Here are some scenarios where we can easily use filter selector. Its very useful for a complex filter.
Some of the scenarios are;
- Dynamically setting the selected option of a dropdownlist
$('#dropdownlistId option').filter(function() { return $.trim( $(this).text() ) == "Value to Compare"; }) .attr('selected',true);
- Dynamically changing the background color of a particular checked checkbox.
$('input:checked').filter(function() { return $.trim( $(this).val() ) == "Value to Compare"; }) .css('background-color','#fff');