Reputation: 83
Code as it appears now:
<p class="intro" id="186949"><span class="namepart"><span class="name">john cena</span></span>
Code as I want it to appear:
<p class="intro" id="186949"><span class="namepart"><span class="name">john cena</span><span class="special">name2</span></span>
I'd like to append another span to the end of "john cena" Using Jquery, but only to that specific post, with the ID "186949"
I know I have to use append, but I don't know how to ensure that the span goes only in that post, and after the name span.
Upvotes: 0
Views: 40
Reputation: 28837
Check here Fiddle
var content = '<span class="special">name2</span>';
$(content).insertAfter('#186949 .name');
Upvotes: 1
Reputation: 33870
Try this :
$('#186949 .namepart .name').after($('<span/>', {class : 'special', text : 'name2'}))
Upvotes: 5