Jquery Wildcard selectors.

Jquery Wildcard selectors.

Last updated:

I have only just come across these so I think others may not know about this either. You can specify wildcards as JQuery selectors.

To select all input elements whose id start with foo, and bind a function to their onclick event, you would do this:

$('input[id^=foo]').click(function(){
      alert('i got clicked!');
    });

More info at the official website

Dialogue & Discussion