我有这个:
document.getElementById('returning_user_search_box').style.backgroundColor='yellow';
现在我需要添加更多这样的样式:
margin-left:-280px; margin-top:-280px; min-width: 550px;
我尝试了一些这样的组合但没有成功:
document.getElementById('returning_user_search_box').style.innerHTML='{margin-left:-280px; margin-top:-280px; min-width: 550px;}';
有什么线索吗?
最佳答案
你必须单独设置它们:
var style = document.getElementById('returning_user_search_box').style;
style.backgroundColor = 'yellow';
style.marginLeft = '-280px';
style.marginTop = '-280px';
style.minWidth = '550px';
关于javascript - 在 JS 中包含 CSS 多属性的正确语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18390455/