<div id="story">
<p>lorem ipsum...</p> // for example this is clicked
<textarea></textarea>
<p>lorem ipsum...</p> // need to select
<textarea></textarea>
<p>lorem ipsum...</p>
<textarea></textarea>
</div>js
$("#story > p").click(function() {
var a = $(this).next("p").html();
});单击一个段落,我需要选择下一个段落,而不是下一个元素(本例中为textarea)。
发布于 2016-01-14 19:11:58
next只搜索直接的下一个元素。使用nextAll代替如下所示。
$("#story > p").click(function() {
var a = $(this).nextAll("p:first").html();
});https://stackoverflow.com/questions/34797684
复制相似问题