focus与定位
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(function(){ $("#button1").click(function() { $("#firstName").focus().select(); }); $("#button2").click(function() { $("#checkbox1").focus().select(); }); $("#button3").click(function() { $("#radio1").focus().select(); }); $("#button4").click(function() { var scroll_offset = $("#pos").offset(); $("body,html").animate({scrollTop:scroll_offset.top},0); }); }); </script> </head> <body> <input type="text" name="FirstName" id="firstName" value="Hello World" /> <input type="checkbox" id="checkbox1"/><label for="checkbox1">CheckBox</label> <input type="radio" id="radio1"/><label for="radio1">radio</label> <input type="button" id="button1" value="选中text"/> <input type="button" id="button2" value="选中checkbox"/> <input type="button" id="button3" value="选中radio"/> <input type="button" id="button4" value="定位"/> <div> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe qwetraweftqwe</br> qwetraweftqweqwetraweftqwe qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe qwetraweftqwe</br> qwetraweftqweqwetraweftqwe qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe qwetraweftqwe</br> qwetraweftqweqwetraweftqwe qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe qwetraweftqwe qwetraweftqwe qwetraweftqwe qwetraweftqwe tqwerwq </div> <span id="pos"> 定位 </span> <div> qwetraweftqweqwetraweftqwe</br> qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqwe</br> qwetraweftqweqwetraweftqwe qwetraweftqweqwetraweftqweqwetraweftqweqwetraweftqwe qwetraweftqwe qwetraweftqwe qwetraweftqwe qwetraweftqwe qwetraweftqwe tqwerwq </div> </body> </html>