I am trying to find id of ul which doesnot have any li element in code below:
if ( $("#myDiv ul.myClass > li").length < 1 ){
alert($(this).attr("id"));
}
I also saw this article but it uses .each() function. I want to achieve this without using any looping. Is this possible?
In the JSFiddle above, I am unable to get the ID of the empty UL element. It is alerting that it is undefined.
Could anyone please let me know what I am doing wrong here?