简体   繁体   中英

How to wrap text into SPAN Tag?

I have below format text in my file.

<p>
hi
<span class="start"></span>
inside span
<span class="start"></span>
</p>

How do I convert it into Like this

<p>
hi
<span class="start"></span>
<span class="wrap">inside span</span>
<span class="start"></span>
</p>

Edit:

What I am trying to do is

$('.start').next().contents().wrap('<span class="wrap"/>'); 

But it is not Working well.

DOM元素具有nextSibling属性,该属性包括文本节点和JQuery能够识别的属性。

$($('.start')[0].nextSibling).wrap('<span class="wrap"></span>');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM