two methods:
1. set the enclosing div's scrollTop to the enclosed div's offsetTop if you have the div's lined vertically
2. use scrollIntoView method:
<div id="enclosing" style="overflow:auto; width:400; height:300">
<div id="enclosed1" style="background-image:url(Back.jpg);width:320; height:240;color:blue;font-size:20">11111111</div>
<div id="enclosed2" style="background-image:url(Back.jpg);width:320; height:240;color:blue;font-size:20">22222222</div>
<div id="enclosed3" style="background-image:url(Back.jpg);width:320; height:240;color:blue;font-size:20">33333333</div>
</div><input type=button onclick="enclosing.scrollTop = enclosed3.offsetTop" value="Use scrollTop and offsetTop">
<input type=button onclick="enclosing.scrollTop=0" value="Reset">
<input type=button onclick="enclosed3.scrollIntoView()" value="Use scrollIntoView">Of course, you can also use scrollLeft and offsetLeft if you have the div's positioned horizontally.
1. set the enclosing div's scrollTop to the enclosed div's offsetTop if you have the div's lined vertically
2. use scrollIntoView method:
<div id="enclosing" style="overflow:auto; width:400; height:300">
<div id="enclosed1" style="background-image:url(Back.jpg);width:320; height:240;color:blue;font-size:20">11111111</div>
<div id="enclosed2" style="background-image:url(Back.jpg);width:320; height:240;color:blue;font-size:20">22222222</div>
<div id="enclosed3" style="background-image:url(Back.jpg);width:320; height:240;color:blue;font-size:20">33333333</div>
</div><input type=button onclick="enclosing.scrollTop = enclosed3.offsetTop" value="Use scrollTop and offsetTop">
<input type=button onclick="enclosing.scrollTop=0" value="Reset">
<input type=button onclick="enclosed3.scrollIntoView()" value="Use scrollIntoView">Of course, you can also use scrollLeft and offsetLeft if you have the div's positioned horizontally.
第一种方法适合我的工作
在你的配合下我看我在周末就可以完成我的工作了。