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怎么写?的详细内容。