var aDiv = document.getElementsByTagName('div');//获取的标签名
注意你下面用的是哪一个div的标签名,例如 aDiv[0] 才可以;
<!-- 注意获取标签TagName时,要表明是哪一个下标标签的:aDiv[ 0 ] -->
<script> var aDiv = document.getElementsByTagName('div'); var timer = null; aDiv[0].onmouseover = function(){ timer = setInterval(function(){ var dWidth = parseInt(getComputedStyle(aDiv[0]).width); aDiv[0].style.width = (dWidth + 10)+ 'px'; }, 1000); } aDiv[0].onmouseout = function(){ clearInterval(timer); } </script>