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.
精彩评论