hallo all. i am trieng to build a function that gets all ul's on screen that have less then 3 li elements. i need this as a jquery object. so i dont mind if it will be a function or just one selector.
how do i do it?
thanks
hallo all. i am trieng to build a function that gets all ul's on screen that have less then 3 li elements. i need this as a jquery object. so i dont mind if it will be a function or just one selector.
how do i do it?
thanks
You can use .filter() for this, for example:
$("ul").filter(function() { return $(this).children().length<3; }).doSomething();
With this we're getting all <ul> elements, then filtering down to only those who have fewer than 3 children, by checking the .length of .children().