Okay I have a jQuery dialog box which has a form in it and I am at my wits end trying to figure this out... Lets see if I can verbalize what I am trying to do..
I ha
jQuery always returns an array of elements. If no matches were found, the array will be empty. An empty array in Javascript evaluates to true:
console.log( !![] ); // logs: true
You want to check the length of the returned set:
if ( ! $("#mylist li").length ){
$('#popuperrors').hide();
}
I like using the children()
method because it reads nicely and it works even if you've already cached the selector for your ul. Here's what it looks like:
$myList = $('#myList')
if ( $myList.children().length === 0 ) ...
if ($('#mylist li').length == 0) ...