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

<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进行。

我认为在没有修改原始代码的情况下,这样做非常困难,因为您没有跨度或要查询的任何内容。

09-10 12:07
查看更多