views:

242

answers:

2

Hi guys I want to be able to append divs to my page such that they are appended after a div of a certain class and before teh divs that follow it i.e:

<div class="header">Header DIV</div>
<!-- Want to add using javascript some HTML right here-->
<div class="one-basic-div">...</div>
<div class="one-basic-div">...</div>
<div class="one-basic-div">...</div>
<div class="one-basic-div">...</div>

Its basically raw html I wish to add - how can I do it.

+1  A: 

Is this the function you are looking for?

// both should work
$('header').insert({after: '<p>some html</p>'})
$$('#header')[0].insert({after: "<p>some html</p>"});
Salman A
THanks alot :D works great
Ali
+1  A: 

Use insert:

$$('#header').insert({ 'after' : theHTML });

That should insert it as a sibling after the div with id header.

There are some helpful examples here, the documentation seems to be lacking, somewhat.

karim79
Thanks man I wish I could mark all answers right :D
Ali
I think you'll have to add a `[0]`.
Salman A