innerText兼容处理
来源:互联网 发布:linux执行命令后循环 编辑:程序博客网 时间:2024/06/05 07:01
IE、Safari、Opera和Chrome支持innerText属性。Firefox虽然不支持innerText,但支持作用类似的textContent属性。textContent是DOM3级规定的一个属性,而且也得到了safari、opera和Chrome的支持。为了确保跨浏览器兼容,有必要想下面这样通过函数来检测可以使用哪个属性:
var div = document.getElementById("content");function getInnerText(element) { return (typeof element.textContent == "string") ? element.textContent : element.innerText;}function setInnerText(element, text) { if (typeof element.textContent == "string") { element.textContent = text; } else { element.innerText = text; }}setInnerText(div, "Hello world!");alert(getInnerText(div)); //"Hello world!"
1 0
- innerText兼容处理
- 火狐FF和IE兼容下innerText的问题处理
- innerText 兼容火狐 ie浏览器
- innerText兼容火狐和IE
- innerText兼容火狐和IE
- 兼容的用innerHTML模拟实现innerText
- innerText和textContent区别及浏览器兼容
- jquery处理innerText与textContent
- innerText
- innerText
- IE和火狐的不兼容之innerText和textContent
- 低版本Firefox支持innerText属性兼容方法
- ARC 兼容处理
- swapNode兼容处理
- insertAdjacentElement兼容处理
- placeholder 兼容处理
- ajax处理浏览器兼容
- IE兼容处理
- SQL性能优化前期准备-清除缓存、开启IO统计
- Jni反破解调研
- 104. Maximum Depth of Binary Tree
- Android 环形进度条Demo
- img标签的onerror事件
- innerText兼容处理
- 升级SDK后出现:This Android SDK requires Android ... update ADT to the latest version
- tongEASY
- jar文件读取和遍历
- Makefile的实例讲解
- UVa 10391(Compound Words)
- maven 无法导入jar包
- hdu 5151 Sit sit sit(区间DP+组合数学)
- Android 绘图(二) Canvas