Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge Paragraph

I am new to Jquery, My requirement is to merge two paragraphs into single paragraph. I have tried using the following code.

<p>This is first para text </p>
<p>This is second para text </p>
<p>This is third para text.</p>

into

<p>This is first para text This is second para text This is third para text.</p>

It doesn't work. Any ideas?

like image 307
subash Avatar asked Feb 17 '26 04:02

subash


1 Answers

Only one line code:

$('p').contents().unwrap().wrapAll('<p>');

See the demo.

like image 193
xdazz Avatar answered Feb 18 '26 17:02

xdazz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!