JS常见知识点
oDiv.style.width;//该方法只能获取行间样式,获取不到非行间样式。
取非行间样式
(1)var w = getComputedStyle(oDiv).width;//IE8及以下不兼容。
(2)var w = oDiv.currentStyle["width"];//IE6,7,8专有,但标准浏览器不兼容。
(3)对象.属性 ----> 对象["属性"]。
//兼容处理:function getStyle(obj,attr){ return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj)[attr];}
set/getAttribute
oInput.setAttribute("style","background:red");oInput.getAttribute("style");//返回字符串oInput.setAttribute(attrName,attrValue);oInput.getAttribute(attrName);oInput.getAttribute("class");//IE6,7不兼容,返回null值。oInput.getAttribute("className");//IE6,7适用,标准浏览器及IE8及以上不兼容。
cssText
oDiv.style.cssText = "width:200px;height:200px;background:red;"
2.属性相关
(1) innerHTML:闭合标签的内容
(2) value
(3) className
(4) fontSize
(5) src
(6) document.write("");document.body.innerHTML=""
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。