获取innerHtml,但删除不需要的标签 [英] Get innerHtml but remove unwanted tags

查看:328
本文介绍了获取innerHtml,但删除不需要的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,我如何获得innerHtml没有html标签。只有文本。

解决方案

如果你不使用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.

这篇关于获取innerHtml,但删除不需要的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆