JQuery – Check if child div is visible

jquery

I'm trying to see if the the child div of an li is visible and if so apply a class to the li. This is what I got but it's not working.

if(jQuery('#menu li').children('div').css('display') != 'none') {
    jQuery('li', this).addClass('dropHover');
}

Best Solution

if (jQuery('#menu li > div').is(':visible')){
    //...
    jQuery('li', this).addClass('dropHover');
}

I don't know what is the DOM structure or to what this refers to, but this might do the trick as well:

jQuery('#menu li:has(div:visible)').addClass('dropHover');

    It adds the class "dropHover" to all <li> elements that have a visible <div>
and they need to be children of an element with the menu id.