标签:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <style> #div1{width:400px;height:400px;background-color:blue;} </style> <body> <div id=‘div1‘> </div> <input type=‘button‘ value=‘big‘ onclick=‘big();‘ /><br/> <input type=‘button‘ value=‘bigger‘ onclick=‘bigger();‘ /> <script> function big(){ var div1=document.getElementById(‘div1‘); div1.style.width=800; } function bigger(){ var div1=document.getElementById(‘div1‘); div1.style.width=100;
var width=div1.style.width || div1.clientWidth || div1.offsetWidth || div1.scrollWidth;
/*实际用div1.offsetWidth就够了,上边的麻烦了*/
alert(width);
}
</script>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/FightingTT/p/4642802.html