innerHtml innerText textContent兼容性问题
innerHtml,innerText,textContent
innerHtml获取元素带标签的内容;innerText只获取元素的文本;
火狐不支持innerText,支持textContent;
// IE和Firefox都能用的设置/获取对象属性函数
aobj = document.getElementById("alink");
firefox_ie(aobj,"http://www.test.com")
function firefox_ie(obj,value)
{
if(document.all){
if(typeof(value)=="undefined")
return obj.innerText;
else
obj.innerText=value;
}else{
if(typeof(value)=="undefined")
return obj.textContent;
else
obj.textContent=value;
}
}
innerHtml innerText textContent兼容性问题的更多相关文章
- innerHTML,innerText,textContent,outerHTML的用法以及区别
innerHTML获取的是对象起始的位置到终止位置全部内容,包含html标签. innerText和textContent结果是一样的,不包含标签,直接获取标签内的内容,区别是两者浏览器的兼容性. o ...
- innerHTML..innerText..textContent
/* * innerText和textContent 都是设置文字内容的,如果设置的内容当中有标签,也会直接的以文本的方式显示(标签的<>都会按照转义的方式进行解析) * innerTex ...
- vue-learning:12 - 2 - 区分:outerHTML - innerTHML - outerText - innerText - textContent
区分:outerHTML - innerTHML - outerText - innerText - textContent 获取值 <div id="outer"> ...
- innerHTML,innerText,outHTML,outText区别
<p><div id="div" style="background-color:#ff9966;border:1px #ff0000 dashed;& ...
- innerHTML innerText的使用和区别
document对象中有innerHTML.innerText这两个属性,都是获取document对象文本内容,但使用起来还是有区别的: 1) innerHTML设置或获取标签所包含的HTML+文本信 ...
- innerHTML .innerText区别
().innerHtml("“):改变html元素: ().innerTEXT(”“):改变文本元素: 试验代码 <!DOCTYPE html> <html lang=&q ...
- js 中innerHTML,innerText,outerHTML,outerText的区别
开头说下innerText和outerText只在chrome浏览器中有效 定义和用法 innerHTML 属性设置或返回表格行的开始和结束标签之间的 HTML,包括标签. 来看代码 <!DOC ...
- innerHTML innerText与outerHTML间的区别
innerHTML与innerText及outerHTML间的区别最容易使初学者搞混淆,为了更好的使读者区分开.下面我就通过一个demo来解释: 代码: <!DOCTYPE html>&l ...
- javaScript中innerHTML,innerText,outerHTML,outerText的区别
开头说下innerText和outerText只在chrome浏览器中有效 定义和用法 innerHTML 属性设置或返回表格行的开始和结束标签之间的 HTML,包括标签. 来看代码 <!DOC ...
随机推荐
- Spring MVC学习笔记——Welcome
参考: http://blog.csdn.net/hehexiaoyou/article/details/23747617 http://www.codingyun.com/article/47.ht ...
- Java线程操作方法
取得和设置线程名称 //================================================= // File Name : Thread_demo //--------- ...
- TCP/IP详解
第一篇 TCPIP协议详解 第1章 TCPIP协议族 第2章 IP协议详解 第3章 TCP协议详解 第4章 TCP/IP通信案例:访问Internet上的Web服务器 一.TCP/IP协议族 TCP/ ...
- autofac Adding services after container has been built
http://stackoverflow.com/questions/6173566/run-time-registration-with-autofac Yes you can, using the ...
- jsp七大动作和三大指令
一:include 动态包含(分别编译):用jsp:include动作实现<jsp: include page="included.jsp" flush="true ...
- Orchard源码分析(5.2):BeginRequest事件处理(DefaultOrchardHost.BeginRequest方法)
BeginRequest事件处理的作用是确保所有Shell已经加载,或者在扩展有变化的时候重新加载. void IOrchardHost .BeginRequest() { ...
- 新浪微博客户端(35)-使用NSMutableAttributedString实现多行文本的效果
DJComposeViewController.m import "DJComposeViewController.h" #import "DJAccountTool.h ...
- [asp.net core]project.json(2)
摘要 上篇文章介绍了project.json中的一部分属性.属性真的比较多,所以分开了,考虑到其中的英文比较简单,也不再进行翻译了,从英文原文中,直接粘贴过来了. project.json(1) pr ...
- 10个基础的linux网络和监控命令
配置zookeeper集群时,需要查看本机ip,输入命令 hostname -i 就会只显示主机ip, 下边搜了一篇常用的 命令,闲的时候多敲敲命令,以便用的时候再找! 我下面列出来的10个 ...
- linux下生成core dump文件方法及设置
linux下生成core dump文件方法及设置 from:http://www.cppblog.com/kongque/archive/2011/03/07/141262.html core ...