网络编程 
首页 > 网络编程 > 浏览文章

js调用css属性写法

(编辑:jimmy 日期: 2025/5/12 浏览:3 次 )
1、对于没有中划线的css属性一般直接使用style.属性名即可。
如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。

2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可。
如:obj.style.marginTop,obj.style.borderLeftWidth,obj.style.zIndex,obj.style.fontFamily等。

因为float是Javascript的保留字,那怎么在js中书写样式表中的float呢?
我们不能直接使用obj.style.float来使用,这样操作是无效的。

其正确的使用方法是为:IE:obj.style.styleFloat,其他浏览器Mozilla(gecko),ff等用styleFloat:obj.style.cssFloat。
上一篇:javascript使用isNaN()函数判断变量是否为数字
下一篇:JSP跨iframe如何传递参数实现代码
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 网站地图 SiteMap