obj.style.backgroundColor有时候能取到值,有时候取不到,这是为什么呢?看了下面的代码你就知道了。
<html> <head> <style type="text/css"> p {background-color: #ccc} </style> </head> <body> <p id="demo" class="p">非内联样式。</p> <p id="demo2" style="height:50px; width:250px; margin-top:10px; text-align:center; line-height:50px; background-color:#ccc;">内联样式。</p> </body> </html> <script type="text/javascript"> document.getElementById("demo").onclick = function() { alert( "高度:"+this.style.height+"\n"+ "宽度:"+this.style.width+"\n"+ "上边距:"+this.style.marginTop+"\n"+ "对齐:"+this.style.textAlign+"\n"+ "行高:"+this.style.lineHeight+"\n"+ "背景颜色:"+this.style.backgroundColor ); alert( "高度:"+getRealStyle(this, "height")+"\n"+ "宽度:"+getRealStyle(this, "width")+"\n"+ "上边距:"+getRealStyle(this, "marginTop")+"\n"+ "对齐:"+getRealStyle(this, "textAlign")+"\n"+ "行高:"+getRealStyle(this, "lineHeight")+"\n"+ "背景颜色:"+getRealStyle(this, "backgroundColor") ); }; document.getElementById("demo2").onclick = function() { alert( "高度:"+this.style.height+"\n"+ "宽度:"+this.style.width+"\n"+ "上边距:"+this.style.marginTop+"\n"+ "对齐:"+this.style.textAlign+"\n"+ "行高:"+this.style.lineHeight+"\n"+ "背景颜色:"+this.style.backgroundColor ); }; // 一定要取到值怎么办?可以用下面这个方法。 function getRealStyle(obj, styleName) { var realStyle = null; if(obj.currentStyle) { realStyle = obj.currentStyle[styleName]; } else if(window.getComputedStyle) { realStyle = window.getComputedStyle(obj, null)[styleName]; } return realStyle; } </script>
我个人的理解和结论就是内联样式是可以取到值的,否则是取不到的,一定要取到值怎么办?可以用代码中的getRealStyle(obj, styleName)获取。
相关推荐
一个加载obj文件的程序,希望对你有帮助
rvt2obj_revit导出_revit生成obj_revitobj_rvt2obj_obj.zip
大漠类库生成工具v24.0 能够生成各语言调用大漠的类库。如易语言的obj.txt 工具用法:选择好dm.dll所在的目录后。点击生成。会在dm.dll目录下生成一个Output文件夹。里面包含了各语言调用的类库。
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。 如:obj.style.marginTop,obj....
基于vc++的ply文件的读取和写入,实用于ASCII和binary两种
obj.Parse('{"name":"lee","age":32, "childs":[{"name":"xiao ming","age":2},{"name":"baobao","age":5}]}') ?obj.item("name").value ?obj.item("age").value ?obj.item("childs").count ?obj.item("childs")....
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。 如:obj.style.marginTop,obj.style...
main.OBJ.obj
3D Formats: 3DS, OBJ, SMD, MD2, TIN, PLY, STL 2D Formats: JPG, BMP, TGA, CEL etc. Supports smooth and flat shading, wireframes, hidden lines removal, texturing and antialiasing (if supported by ...
STARTUP.OBJ.obj
import 'package:obj/obj.dart'; 例子 1.解析OBJ字符串 // objURL is an optional URL for issuing the obj location on error messages // objString is a string containing the OBJ text String objURL = ...
obj.Parse('{"name":"lee","age":32, "childs":[{"name":"xiao ming","age":2},{"name":"baobao","age":5}]}') ?obj.item("name").value ?obj.item("age").value ?obj.item("childs").count ?obj.item("childs")....
可以使得3dmax批量导入obj实现批量化,很好,好小巧的3dmax插件。
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position 2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。 如:obj.style.marginTop,obj.style....
1、解压 2、用vs打开编译生成dll文件(或者直接去bin目录找) 3、打开revit外部工具的addin调用dll文件 4、桌面生成对应obj文件夹,里面就是obj文件
error LNK2005: DllMain already defined in corelibc.lib(dllmain.obj)的解决方案
PyWavefront PyWavefront读取Wavefront 3D对象文件( something.obj , something.obj.gz和something.mtl ),并为准备渲染的每种材质生成交错的顶点数据。 1.x版本支持Python 3.4+ 0.x版本支持Python 2.7 还提供了...
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。 如:obj.style.marginTop,obj.style....
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。 2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。 如:obj.style.marginTop,obj.style...
opencv-yolo-tiny车辆检测需要的车辆检测模型文件 yolov3-tiny.weights yolov3-tiny.cfg obj.names