代码如下
1.使用oUl.style.height='1000px'可以改变ul的高度,但是为什么使用oUl.setAttribute('height','1000px')却无法改变;
2.将“height”改成title后,也是有效果的。
<script>
window.onload=function(){
var oUl=document.getElementById('ul');
oUl.setAttribute('height','1000px');
// oUl.style.height='1000px';
}
</script>
<body>
<ul id="ul">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</body>
setAttribute()是用来设置element的属性值的,element没有height属性,你可以试一下oUI.setAttribute('style', 'height: 1000px');