I'm trying to write a script that needs to know whether or not the autocomplete dropdown contains any results. This is what I currently have, but for some reason the IF is not working (ie. the code inside is not being triggered).
if($("ul.ui-autocomplete li").length == 0){
$('div#autocomplete').replaceWith('<h2>' + $(this).val() + '</h2>');
return false;
}
It seems like there are still results, they're just hidden. So how can I see if there are results or if the dropdown autocomplete list is visible?