开发者

How to match the next div (not a child) with jquery

Im sure there is an easy answer for this one, but I've been looking around for a while and can't seem to find it.

Suppose somewhere in my page I have the following code:

<开发者_运维百科;button onclick='$(this).???.show();'>Show</button>
<div style='display:none;'>Content</div>

What I need is some jQuery code instead of the ??? that will match the div RIGHT AFTER the button, remembering that there might be other divs in the page. And of course, giving an id to the div is not an option.

Thanks.


Use .next()

$(this).next().show();


You should use .next() to select the next div.

$(this).next("div").show();

jsFiddle Example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜