[英]Remove html tags apart from the image tag from the string
我有一個關於從圖像標簽中刪除字符串中的html標簽的問題。 假設我們有一個字符串:
<p>MA2: Allow time for editing and other types of question revisions.<span class="AM"> <img src="img" title="{(1 if x>=0),(0 if x<0):}"style="vertical-align: middle;"> </span> <span class="AM"> </span> </p>
在這里我們只需要像html標簽一樣刪除<p>
和<span>
。 但我們需要圖片標簽。
預期結果 :
MA2: Allow time for editing and other types of question revisions.<img src="img" title="{(1 if x>=0),(0 if x<0):}" style="vertical-align: middle;">
提前致謝。
。$( '跨')的內容()解開();
$( 'P')的內容()解開()。;
對於除圖像之外的所有元素
$('*').not('img').contents().unwrap();
更多信息:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.