我在页面中多次使用此部分:
<a class="showComment" style="cursor: pointer;"><i class="icon-comment"></i> Views</a>
<br />
<br />
<div class="writeComment" style="height: auto; width: 700px;" dir="ltr" hidden="hidden">
</div>
Run Code Online (Sandbox Code Playgroud)
我现在正在js文件中为a.showCommentclick事件编写代码.现在我想选择下一个.div.writeComment如何选择它?
next() 不起作用。
nextAll() 适用于我的 .showComment 元素之后的所有 .writeComment 元素。但是我发现了问题。以下代码解决了这个问题。
$('.showComment').click(function(){
$(this).nextAll(".writeComment").first();
});
Run Code Online (Sandbox Code Playgroud)