I would like use the function wrap of jquery, or maybe with an other solution, but I need to wrap a content of div, with exclude specific tag like <sup>
<i>
<strong>
. I explain with an example bellow
I have this :
<div>
my test without tag<sup>1</sup> and the end of sentence.
<p>text with tag p <br />
break line
</p>
Second sentence without <i>tag</i> and the end.
<div>
I would like this :
<div>
<p>my test without tag<sup>1</sup> and the end of sentence.</p>
<p>text with tag p <br />
break line
</p>
<p>Second sentence without <i>tag</i> and the end.<p>
<div>
So I do this in JS with JQuery,
$( "div" )
.contents()
.filter(function(){
return this.nodeType !== 1;
})
.wrap( "<p></p>" );
But this JS do this :
<div>
<p>my test without tag</p>
<sup>1</sup>
<p> and the end of sentence.</p>
<p>text with tag p <br>
break line
</p>
<p>Second sentence without </p><i>tag</i><p> and the end.</p>
</div>
I create this jsFiddle