If I have Checkboxes in page with IDs like below
a_chk1, a_chk2, a_chk3, b_chk1, b_chk2, b_chk3, c_chk1, c_chk2
If I want to retrieve checkboxes with ID starting with “a_”. The below code done my work
$(':checkbox').filter(function(){return $(this).prop('id').indexOf("a_") > -1;})
But it iterates through each checkbox and filters the required elements. But is there any possibility of iterating through only qualified elements.
You can let jQuery do all the work for you in the selector like this:
Working demo here: http://jsfiddle.net/jfriend00/5qENn/