To provide three of the use of JS to obtain div width code Oh, the first simple and practical, the second access to the div width and height of the JS instance, the third instance is an S to get the specified div inside all the picture height and width code.
<html> <head> <title>test page</title> </head> <body> <table style= "width:100%;" <tr> <td> <div id= "Div1" Style= "Background:green;" >div1</div> <td> <td style= "width:50%;" <div id= "Div2" style= "background-color:red;" >div2 www.jzread.com</div> <td> </table> <input type= "button" Onclick= ' Show () ' value= ' show '/> <script> function Show () { var o = document.getElementById ("Div1"); var w = o.clientwidth| | O.offsetwidth;
alert ("Div1 s width is" wheels); } </script> </body> </html> Here is a use of JS to get the specified div inside all the picture height and width js How to get this div inside the width of the picture and
<script> var obj=document.getelementbyid ("Pal"); var imgs=obj.getelementsbytagname ("img"); Var sum=0; for (var i=0;i<imgs.length;i++) sum+=imgs[i].width Alert (sum); </script>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.