綜觀「In jQuery, want to remove all HTML inside of a div」,我竟能在正確的方向是什麼我正在尋找中刪除HTML
<textarea id="inputPane" cols="80" rows="40" class="pane" style="height:300px;">
<table><tr><td>
<b>Since your service bureau</b>, xxx is not certified
by our company for xyz, your company will need to complete
more testing as part of the process.
</td></tr></table>
</textarea>
使用從上面列出的URL這個代碼,我能明顯地移除所有的空格,但我無法刪除實際的HTML標籤:<b></b>
,<table>
等
jQuery.fn.stripTags = function()
{ return this.replaceWith(this.html().replace(/<\/?[^>]+>/gi, '')); };
這部分是什麼意思?
/<\/?[^>]+>/gi
我覺得有這麼一句話:
- 刪除此字符,
<
- 並刪除這個人物
>
- 和什麼也沒有更換。
雖然這不是它在我的代碼中所做的。它似乎從我放置的DIV中除去所有空白。
什麼是gi
部件? 而且,當HTML顯示來自數據庫時,您是否有一個很好的解決方案來從wmd-editor textarea中移除HTML標記?
'gi'意味着圖案全球應用,並忽略大小寫。 – 2012-12-03 14:16:22