使用 $(this)? 在 2 个元素之后添加一些内容?

Add something after 2 elements using $(this)?

我想在 $(this) 的第二个或第三个元素之后添加一些内容。这实际上始终是一种形式,只是为了让您知道。在这个表格之后还有一些其他元素,最后还有另一个表格,您可以从那里返回。

如果已创建评论,我想在此表格后添加一条消息,但我该怎么做:

$(this).after.after("<p class='success'>The comment has been edited!</p>");

或者类似的东西,我还可以在哪里使用表单的 class 的名称?其实回去的表格有名字回来。

我实际上需要使用 $(this),否则会为每条评论添加消息。

要定位下一个元素(如果它是表单),请使用 .next('form')

$(this).next('form').after("<p class='success'>The comment has been edited!</p>");

要在两个或三个元素之后定位某些内容,您可以使用当前索引并添加到​​它,然后使用 eq 获取该同级元素

$(this).siblings().eq($(this).index() + 2)

要在下一个 最近的 形式之后插入,请使用 .nextAll('form')[0]

$("<p class='success'>The comment has been edited!</p>")
.insertAfter($(this).nextAll('form')[0]);

这将在表格第一次出现后插入 HTML(在 $(this) 之后)