This article mainly introduces the small rules and examples of JS dynamic call CSS Properties. Need friends can come to the reference, I hope to help you
Just see a good article about JS call CSS properties, (^_^) Good! Forget yourself, sum up 1, for CSS attributes without underlining, use style. Property name. such as: Obj.style.margin,obj.style.width,obj.style.left,obj.style.position and so on. 2, for the CSS attribute with the underline, remove each underline and capitalize the first character after each underline. such as: Obj.style.margintop,obj.style.borderleftwidth,obj.style.zindex,obj.style.fontfamily and so on. Because float is a reserved word for JavaScript, how do you write float in a style sheet in JS? We cannot use obj.style.float directly, so the operation is invalid. The correct way to use it is: IE:obj.style.styleFloat, other browsers Mozilla (Gecko), FF and other styleFloat:obj.style.cssFloat. Give an example to let everyone understand: The code is as follows: <div onclick= "alert (this.style.float); This.style.float= ' left '; alert (this.style.float); " > Test 1</div> <div onclick= "alert (this.style.float); if (this.style.cssFloat) {this.style.cssfloat= ' left '; }else{this.style.stylefloat= ' left '; }alert (this.style.float); " > Test 2</div>