以下代码适用于firefox,但在IE中显示错误。
document.getElementById('zip_container').style.borderLeft = '1px solid #D9D9D9;';其中zip_container是一个div。
有没有人能对此有什么建议。
发布于 2011-09-02 16:05:55
无效值:
document.getElementById('zip_container').style.borderLeft = '1px solid #D9D9D9;';使用style.something修改样式属性时,";“不是必需的
但如果您要这样修改它:
document.getElementById('zip_container').style.cssText += ";border-left:1px solid #D9D9D9;";
";“不能丢。所以正确的方法是:
document.getElementById('zip_container').style.borderLeft = '1px solid #D9D9D9';
发布于 2011-09-02 16:02:35
document.getElementById('zip_container').style.borderLeft = '1px solid #D9D9D9';(值中没有; )在任何地方都有效。
当您通过javascript设置属性值时,您只需设置该值。;是内联样式中不同样式定义之间的分隔符。当使用javascript更改属性时,您不需要(不应该)提供它。
发布于 2011-09-02 15:59:44
也许你需要添加完整的代码示例,以便更清楚地了解你的问题是什么,但就我所知,如果你使用jQuery来做这件事,你可能就没有麻烦了。
https://stackoverflow.com/questions/7280617
复制相似问题