开发者

jquery help with next() function

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜