行内style的写法为:1、对复合属性的写法是去掉中间的“—”,并将第二个单词大写,代码为【alert(box.style.color)】;2、float是关键字有特殊写法,代码为【alert(box.style.float)】。

JS中行内style的写法为:
1、访问元素样式1, stye属性只对行内样式有用
var box = document.getElementById("box");2、对复合属性的写法是去掉中间的“—”,并将第二个单词大写。
// alert(box.style.color); // alert(box.style.fontSize);
3、float是关键字,因此最好不要这样写
//alert(box.style.float);
4、对float属性ie和非ie有差异:
// alert(box.style.cssFloat); //非ie // alert(box.style.styleFloat); //IE专用
5、给float赋值,且兼容所有浏览器
// typeof box.style.cssFloat !="undefined"?box.style.cssFloat = "right":box.style.styleFloat ="right";
相关学习推荐:javascript视频教程
以上就是JS中行内style怎么写?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号