<!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> <title>jquery聚焦文本框 - 计划 - 博客园</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> </head> <body> <form action="http://www.google.com.hk" id="cse-search-box"> <div> <input type="hidden" name="cx" value="partner-pub-7740261255677392:7064996710" /> <input type="hidden" name="ie" value="UTF-8" /> <!--文本框--><input type="text" name="q" size="25" /> <input type="submit" name="sa" value="搜索" /> </div> </form> <script type="text/javascript"> $(document).ready(function () { $("input[name='q']").focus(); })</script> </body> </html>