Posts Tagged ‘Elements’

How to find the number of selected elements in jQuery?

jQuery selectors return an array so we can use the length property. var num = $("#menu li").length; Alternatively we can use the size() method which returns the same value. var num = $("#menu li").size();