开发者

Append li after current li

I would like to append a li in a ul after my current selection.

I bound a click event to the li, and when it's clicked, another li has to be added 开发者_如何学Pythonafter the current.

What I have now is:

$(this).parent().append('<li>test</li>');

But this just adds the li to the ul, not after the current li.

Is there a way to do that?

Thanks in advance


Use the quite aptly-named .after() method:

$(this).after('<li>test</li>');


Use insertAfter() and pass your this as the argument.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜