开发者

How do you add extra html after an element with jQuery?

I'm aware of jQuery's append() which appends html inside the selected element. I want to add more html after the selected element. For instance:

<a href="/somewhere/">Somewhere</a>

I want to add the html <h3>Hello</h3> after the above to become:

开发者_Go百科
<a href="/somewhere/">Somewhere</a>
<h3>Hello</h3>

How can you achieve that in jQuery?


after


To address your problem, here is the full code:

$('a[href=desired_url]').after('<h3>Hello</h3>');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜