关于obj.currentStyle.property、window.getComputedStyle(obj,null).property、obj.style.property的理解
首先是obj,style.property
我一直用这个obj.style.property这个属性来修改内联和外联的obj属性,但是从网上看到了obj.style.property居然只能读取内嵌的样式,不能读取外联和内联的样式,自己试了一下,果然是这样,自己找的例子是改变ul的width属性,看到的小伙伴可以去试试,对于内嵌的属性是可读写,但是对于内联和外联的属性就是只写,不可读
然后是其他两个,这两个的功能很强大,之所以有两个,是为了要兼容IE
obj.currentStyle.property 是IE浏览器的孤僻的支持的获取元素属性值得方法,可以获得任何位置设置的元素的属性值,包括内嵌式,内联式,外联式; 就是可以得到所有的属性,但是不能改写属性,只读不可写
window.getComputedStyle(obj,null).property 是一个比较大众的方法,谷歌,火狐,opera,sarifi都支持该方法获取元素的属性,其中第二个参数是伪类,如果需要获取的不是伪类,需要将该值设置为null;
obj.style.property只能获取元素的内嵌式样式属性值,其他两个可以获取内嵌式,内联式 ,外联式中设置的属性值。
关于obj.currentStyle.property、window.getComputedStyle(obj,null).property、obj.style.property的理解的更多相关文章
- js计算机样式window.getComputedStyle(ele,null)2
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js计算机样式window.getComputedStyle(ele,null)与
一.getComputedStyle兼容IE8以上,范户籍的计算样式的值都是绝对值,没有相对单位(如:width:10em; 它打印出来是160px) window.getComputedStyle( ...
- window.getComputedStyle()方法的使用及其扩展
1.window.getComputedStyle()方法返回值 是一个可以获取当前元素所有最终使用的CSS属性值.返回的是一个CSS样式声明对象([object CSSStyleDeclaratio ...
- jquery easyui datagrid 空白条处理 自适应宽高 格式化函数formmater 初始化时会报错 cannot read property 'width'||'length' of null|undefined
1---表格定义好之后右侧可能会有一个空白条 这个空白条是留给滚动条的,当表格中的一页的数据在页面中不能全显示时会自动出现滚动条,网上有很多事要改源码才可以修改这个,但是当项目中多处用到时,有的需要滚 ...
- org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'null' to required type 'double' for property 'band'; nested exception is org.springframework.core.convert.Con
本文为博主原创,未经允许不得转载: 先将异常粘贴出来: 20:37:26,909 ERROR [com.suning.fucdn.controller.ProductDataStaticsContro ...
- VC编译错误: Nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12已经在dllmain.obj 中定义
错误: Nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12已经在dllmain.obj 中定义 解决: 打开项目属性对话框, C/C++ -& ...
- window,getComputedStyle,letter-spacing
js 拿到element的css样式 window.getComputedStyle(ele,[pseuso) 比如想拿到一个element的背景色 window.getComput ...
- window.getComputedStyle——ref
componentDidMount() { const LeftHeight = window.getComputedStyle(this.leftDom).height; console.log(L ...
- 使用 <!-- 指定使用hibernate核心配置文件 --> <property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
在bean.xml文件中,这样使用出现问题 <!-- 指定使用hibernate核心配置文件 --> <property name="configLocations&quo ...
随机推荐
- 继承—Monkey
public class Monkey { public void Monkey(String s){ } public void speak(){ System.out.println(" ...
- spinlock参考资料
spinlock:http://irl.cs.ucla.edu/~yingdi/web/paperreading/smp_locking.pdf
- html5开发页游(前话)
导师要求模仿某个页游网站开发益智小游戏.老板的要求是要跨平台,IOS,Android.PC.Mac等系统主要通过浏览器打开都能用.那个网站的页游是通过flash实现的,使用这种方法肯定不能满足老板的要 ...
- codeforces 400 C Inna and Huge Candy Matrix【模拟】
题意:给出一个矩形的三种操作,顺时针旋转,逆时针旋转,对称,给出原始坐标,再给出操作数,问最后得到的坐标 画一下模拟一下操作就可以找到规律了 #include<iostream> #inc ...
- 3、Go Exit
package main import ( "fmt" "os") func main() { //当使用`os.Exit`的时候defer操作不会被运行 所以 ...
- iOS开发——NSString小结
1.创建常量字符串. NSString *astring = @"This is a String!"; 2.创建空字符串,给予赋值. NSString *astring = ...
- vscode 调试vue.js程序
npm install -g vue-cli //安装vue-clivue init webpack projectName //创建项目 1.Ctrl+~ 打开命令行 ...
- [Bug]Python3.x SyntaxError: 'ascii' codec can't decode byte 0xe4 in position
安装arch后就没再用python了 昨天管服务器的大佬在跑贝叶斯分类器的时候发现正确率有问题 我赶紧去做优化,然后就有这样的报错 Python 3.6.4 (default, Jan 5 2018, ...
- STM时钟
一.在STM32中,有五个时钟源,为HSI.HSE.LSI.LSE.PLL. ①HSI是高速内部时钟,RC振荡器,频率为8MHz. ②HSE是高速外部时钟,可接石英/陶瓷谐振器,或者接外部时钟源,频率 ...
- JavaScript【1】(数据类型)
JS系列教程(数据类型)[1]