dom manipulation - jquery insert a html block so it starts before the target and ends after the target - is this possible? -
I think you should use HTML code before and after the target by using before < You can add the inserted block of,
insertBefore ()
, after
and insertAfter ()
.
I tried to do something like this
& lt; Script type = "text / javascript" & gt; ("& Lt; div class = 'myContainer' & gt;"); $ ("P"). After ("& lt; / div>" $ (document) .ready (function () {$ ("p").);}); & Lt; / Script & gt; & Lt; P & gt; Paragraph & lt; / P & gt;
But inject me seems to create closed tags automatically, is there a way around this?
Cheers
There is a function for this :) Use, like this :
$ ("p"). Wrap ("& lt; Div class = 'myContainer' & gt;");
This is for each & lt; P & gt;
Wrapper independent, it changes it:
In:
& lt; Div class = 'myContainer' & gt; & Lt; P & gt; Paragraph 1 & lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = 'myContainer' & gt; & Lt; P & gt; Paragraph 2 & lt; / P & gt; & Lt; / Div & gt;
Comments
Post a Comment