jquery insert a html block so it starts before the target and ends after the target - is this possib

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-06-15T10:09:25Z Indexed on 2010/06/15 10:12 UTC
Read the original article Hit count: 100

Filed under:
|

Hi all,

I understand you can add insert blocks of html before and after a target using before(), insertBefore(), after() and insertAfter().

I tried to do something similar to this

<script type="text/javascript">
    $(document).ready(function(){
        $("p").before("<div class='myContainer'>");
        $("p").after("</div>");
    });
</script>

<p>paragraph</p>

But the inject seems to automatically create closing tags for me, is there a way around this?

Cheers

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about dom-manipulation