jQuery count child elements
$("#selected > ul > li").size()
or:
$("#selected > ul > li").length
You can use .length
with just a descendant selector, like this:
var count = $("#selected li").length;
If you have to use .children()
, then it's like this:
var count = $("#selected ul").children().length;
You can test both versions here.