wrapping html paragraphs inside div
Hi!
I am trying to wrap some html paragraphs inside a div element:
<p>1st paragraph</p>
<p>2nd paragraph</p>
<p>3rd paragraph</p>
I want to have this when I select this text from an iframe with window.getSelection():
<div>
<p>1st paragraph</p>
<p>2nd paragraph</p>
<p>3rd paragraph</p>
</div>
and, in case I select 2 paragraphs and a half, the div woud end before </p>:
<div>
<p>1st paragraph</p>
<p>2nd paragraph</p>
<p>3rd parag</div>raph</p>
Thanks in Advance!
softDeveloper
Junior Poster in Training
76 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Could we see your script? Not sure how you did it. By the way, when you do the selection, did you attempt to check the DOM for parent/neighbor nodes instead of only the text selection?
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17
In jQuery, you can use $('p').wrap('div'). Anyway, post more details to get more implementation.
ko ko
Practically a Master Poster
673 posts since Jan 2009
Reputation Points: 120
Solved Threads: 152
Skill Endorsements: 1