clientWidth=width+padding
clientHeight=height+padding
offsetWidth=width+padding+border
offsetHeight=width+padding+border
scrollLeft //元素最左端到窗口最左端的距离
scrollTop //元素最顶端到窗口最顶端的距离
scrollWidth //元素的滚动宽度
scrollHeight //元素的滚动高度
//获取元素的纵坐标
function getTop(e){
var offset=e.offsetTop;
if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
return offset;
}
//获取元素的横坐标
function getLeft(e){
var offset=e.offsetLeft;
if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
return offset;
}
<div id="wrapper_imglist">
<div id="scroller_imglist">
<div id="thelist_imglist">
<div class="imgbox"><a href="#"><img src="images/1.jpg" /></a></div>
<div class="imgbox"><a href="#"><img src="images/1.jpg" /></a></div>
<!-- <div class="imgbox"><a href="#"><img src="images/1.jpg" /></a></div> -->
</div>
</div>
</div>
<!--图片展示操作区-->
<div id="nav_imglist">
<div id="prev_imglist" class="c_grey" onClick="main_pic_scroll.scrollToPage('prev', 0);">〈 上一张</div>
<div class="indicator_num">
<ul id="indicator_imglist">
<li class="active">1</li>
<li>2</li>
<!-- <li>3</li> -->
</ul>
</div>
<div id="next_imglist" onClick="main_pic_scroll.scrollToPage('next', 0);">下一张 〉</div>
</div>
<script type="text/
javascript">
var imgList = document.getElementById('thelist_imglist');
var divNode = imgList.getElementsByTagName('img');
var pageNum = divNode.length;//获得<img>元素个数
var textList = document.getElementById('wrapper_imglist');
var textListWidth = textList.offsetWidth;//获得元素宽度
textListWidth = pageNum * textListWidth;
var scroller_imglist = document.getElementById('scroller_imglist');
scroller_imglist.style.width = textListWidth + 'px';//根据页数动态改变宽度
</script>