I have the following HTML node structure:
<
-
$("div", "#superpics").size();
讨论(0)
-
$('#foo').children('div').length
讨论(0)
-
$("#foo > div").length
Direct children of the element with the id 'foo' which are divs. Then retrieving the size of the wrapped set produced.
讨论(0)
-
$('#foo > div').size()
讨论(0)
-
$("#foo > div").length
jQuery has a .size() function which will return the number of times that an element appears but, as specified in the jQuery documentation, it is slower and returns the same value as the .length property so it is best to simply use the .length property.
From here: http://www.electrictoolbox.com/get-total-number-matched-elements-jquery/
讨论(0)
-
With the most recent version of jquery, you can use $("#superpics div").children().length
.
讨论(0)
- 热议问题