开发者

jquery help with next() function

开发者 https://www.devze.com 2023-02-23 07:52 出处:网络
I have some HTML markup that looks like this, </a> <nav> <ul> <li><a hr开发者_JS百科ef=\"\"><img src=\"/media/icons/view.jpg\" alt=\"Views\"/> 210</a><

I have some HTML markup that looks like this,

        </a>
        <nav>
            <ul>
                <li><a hr开发者_JS百科ef=""><img src="/media/icons/view.jpg" alt="Views"/> 210</a></li>
                <li><a href=""><img src="/media/icons/like.jpg" alt="Likes"/> 45</a></li>
                <li class="jobs"><a href="">52 New Jobs</a></li>
            </ul>
        </nav>
        <ul class="job_listings">
            <li><a href="">Outbound Telesales Assistant &gt;</a></li>
            <li><a href="">Business Development Manager &gt;</a></li>
        </ul
    </li>

The .job_listings is hidden on dom ready and needs to be show when li.jobs a is clicked, I have tried this with the following, jQuery:

$('#jobwall .jobs a').click(function(){
                $(this).next('.job_listing').show();
                return false;
            });


You should get the next element of nav element and not the anchor, and also you are missing s in the .job_listing selector.

Try this:

$('#jobwall .jobs a').click(function(){                 
    $(this).closest("nav").next('.job_listings').show();                 
    return false;             
}); 


Here you go:

$(this).closest('#commonContainer').find('.job_listings').show();
0

精彩评论

暂无评论...
验证码 换一张
取 消