Home > Jquery Good Practices, Jquery in Asp.Net > Uses of Jquery Filter Selector

Uses of Jquery Filter Selector

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;

  1. Dynamically setting the selected option of a dropdownlist
    
      $('#dropdownlistId option').filter(function() {
    return $.trim( $(this).text() ) == "Value to Compare"; })
    .attr('selected',true);
    
    
  2. 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');
    
    
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s