gpt4 book ai didi

javascript - 使用 JQuery 包装元素

转载 作者:行者123 更新时间:2023-11-28 02:58:08 25 4
gpt4 key购买 nike

我确实在页面上的某个位置有一个元素及其内容:

<div style="padding-bottom:9px; font-size:13px;line-height:25px;">          
Fine quality, full grain pebble leather
<br>
<div style="line-height: normal; margin-bottom: 6px; ">
Sophisticated black with detailed accent lining
</div>
Tailored satin ribbon release pull-strap
<br>
Slim back pocket for an ID card or money
<br>
Ultra slim design
<br>
Shock-absorbent construction
<br>
Additional screen padding
<br>
Light and rigid protective layer
<br>
Soft velvet lining with light protective layer
<br>
<div style="line-height: normal; margin-bottom: 6px; ">
Thinner and more streamlined than the Eléga Pouch
</div>
Sena high-quality handmade craftsmanship<br>
</div>

我想要的是用 jQuery 将上面的内容转换为下面的内容(我尝试了不同的方法,但毕竟我有点迷失)

<div style="padding-bottom:9px; font-size:13px;line-height:25px;">            
<div style="line-height: normal; margin-bottom: 6px;">
Fine quality, full grain pebble leather
</div>
<br/>
<div style="line-height: normal; margin-bottom: 6px; ">
Sophisticated black with detailed accent lining
</div>
<br/>
<div style="line-height: normal; margin-bottom: 6px; ">
Tailored satin ribbon release pull-strap
</div>
<br/>
<div style="line-height: normal; margin-bottom: 6px; ">
Slim back pocket for an ID card or money
</div>
<br/>
<div style="line-height: normal; margin-bottom: 6px; ">
Tailored satin ribbon release pull-strap
</div>
<br/>
...
...
...
</div>

你能帮我一点忙吗?

谢谢。

最佳答案

请说我是老式的,但像这样转换标记(特别是像 <br><br/> )应该在原始文件中完成,而不是在浏览器发送并渲染后使用 jQuery 完成。

我认为如果不修改原始代码,您将很难做到这一点,因为您没有跨度或任何可查询的内容。

关于javascript - 使用 JQuery 包装元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2052144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com