jQuery selector performance

Posted by rahul on Stack Overflow See other posts from Stack Overflow or by rahul
Published on 2010-04-12T06:53:06Z Indexed on 2010/04/12 7:03 UTC
Read the original article Hit count: 604

Filed under:
|
|

I have the following two code blocks.

Code block 1

var checkboxes = $("div.c1 > input:checkbox.c2", "#main");
var totalCheckboxes = checkboxes.length;
var checkedCheckboxes = checkboxes.filter(":checked").length;

Code block 2

var totalCheckBoxes = $("div.c1 > input:checkbox.c2", "#main").length;
var checkedCheckBoxes = $("div.c1 > input:checkbox.c2:checked", "#main").length;

Which one of the above will be faster?

Thanks,

Rahul

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about selector