Question

How do you get to the next node below this

For example

<ul id="secondary-nav">
    <li id="isOpen" class="expandable">
        <p>
            <ul style="display: none;">
    </li>
    <li id="isClosed" class="expandable expanded">
        <p>
            <ul style="display: none;">
    </li>
</ul>

Below is the running code:

$('#secondary-nav li').click(function() {
    var fstname = $(this).attr('class');
    alert(fstname);
    if (fstname == 'expandable') {
        if ($('#secondary-nav li').hasClass('expandable expanded')) {
            $('#secondary-nav li').removeClass('expanded');
            $('#secondary-nav li ul').css('display', 'none');
        }
    }
    $(this).addClass('expanded');
    //******************************//
    $(this).next('ul').css('')
});​

How would I get access to the <ul> element below this at //*********// to change the style of this element.

Was it helpful?

Solution

use find:

$(this).find('ul');

OTHER TIPS

$("ul", this)

That should do the trick as long as it is a child.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top