在Javascript中设置CSS属性? [英] Set CSS property in Javascript?
本文介绍了在Javascript中设置CSS属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了以下内容...
I've created the following...
var menu = document.createElement('select');
我现在如何设置CSS属性,例如 width:100px
?
How would I now set CSS attributes e.g width: 100px
?
推荐答案
使用 element.style
:
var element = document.createElement('select');
element.style.width = "100px";
这篇关于在Javascript中设置CSS属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文