且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取innerHtml,但删除不需要的标签

更新时间:2022-10-14 19:07:21

如果你不使用jQuery(或者即使你是),这个链接探索一些不同的选项(例如innerText vs textContent),以及它们在浏览器之间的差异: -textcontent-html-and-text /> http://www.davidtong.me/innerhtml-innertext-textcontent-html-and-text/




I want to know that how can i get innerHtml without the html tags. Only the text.

If you're not using jQuery (or even if you are), this link explores some of the different options (eg innerText vs textContent), along with how they differ between browsers:

http://www.davidtong.me/innerhtml-innertext-textcontent-html-and-text/

Basically, not all approaches work in all browsers, and some strip line breaks while others don't.