javascript宽度/高度不起作用和颜色

时间:2014-08-15 23:33:17

标签: javascript html css html5 css3

<http://jsfiddle.net/skarchmit/dndumodr/2/>

我通常会使javascript工作,但这个简单的操作无效。 (可以在JSFIDDLE上看到更多代码。)注意:#PHOTOS IS附加到UL

JAVASCRIPT:

function resize(){
document.getElementById('photos').width = "100px !important";
}

CSS:

#photos{
width: 500px;
display: block;
border: 2px solid red;
background-color: yellow;
}

2 个答案:

答案 0 :(得分:6)

如果你想改变css宽度,试试这个:

document.getElementById('photos').style.width = "100px";

答案 1 :(得分:0)

Document.getElementById('photos')。style.width =“100px”;

.WIDTH