Reputation: 3126
I'm completely new to jQuery. To be honest it is my first few days.
And there is my first question.
$(document).ready(function() {
$('span.head-span').parent().addClass('head-h').append('<div class="clx" />')
});
As a result I have this
<h1 class="head-h"><span class="head-span">This is Some Heading</span><div class="clx"/></h1>
What do I need to do in jQuery so my .clx will appear after . like this
<h1 class="head-h"><span class="head-span">This is Some Heading</span></h1><div class="clx"/>
Thank you very much in advance.
Upvotes: 10
Views: 14176
Reputation: 138017
If you want the div after the header, don't append it, use the after
method:
$('h1').after('<div class="clx" />');
Upvotes: 4
Reputation: 887433
Use the after
method, like this:
$('span.head-span').parent().addClass('head-h').after('<div class="clx" />')
Upvotes: 3