Closed LiuL0703 closed 6 years ago
onInput 属性实时监控< input> 或者中的value值得变化状况 Object.target.value.length 可以获取文本框中的字符长度 onInput事件类似于 onchange 事件。不同之处在于 oninput 事件在元素值发生变化是立即触发, onchange 在元素失去焦点时触发。另外一点不同是 onchange 事件也可以作用于 < keygen> 和 < select> 元素
关于getComputedStyle() 与style直接获取元素的CSS属性值相比 style仅能获取内嵌在html代码中的css元素属性 而 getComputedStyle则都可以获取 但是是只读属性[针对IE的话要用currentStyle属性] 兼容一下的话: (element.currentStyle? element.currentStyle : window.getComputedStyle(element, null)).height getPropertyValue方法可以获取CSS样式申明对象上的属性值(直接属性名) 例如:window.getComputedStyle(element, null).getPropertyValue("float");
onInput 属性实时监控< input> 或者
关于getComputedStyle() 与style直接获取元素的CSS属性值相比 style仅能获取内嵌在html代码中的css元素属性 而 getComputedStyle则都可以获取 但是是只读属性[针对IE的话要用currentStyle属性] 兼容一下的话: (element.currentStyle? element.currentStyle : window.getComputedStyle(element, null)).height getPropertyValue方法可以获取CSS样式申明对象上的属性值(直接属性名) 例如:window.getComputedStyle(element, null).getPropertyValue("float");