I would like to know how I add elements above and below various paragraphs with jquery.
Let's say, I have to get the third paragraph and add a <div>
and I finish the </div>
in the penultimate paragraph.
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
The result would be this:
<p>1</p>
<p>2</p>
<div>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</div>
<p>7</p>
I tried with after
and before
, but the browser closes the tags.