<!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></title> </head> <body> <input type="text" id="address" value="请输入邮箱地址" /><br /> <input type="text" id="password" value="请输入邮箱密码" /> <input type="button" value="登录" /> <select id="single"> <option>1号</option> <option>2号</option> <option>3号</option> </select> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#address").focus(function () { var txt_value = $(this).val(); //val获取元素的值 if (txt_value == "请输入邮箱地址") {//val设置元素的值 $(this).val(""); } }) $("#address").blur(function () { var txt_value = $(this).val(); if (txt_value == "") { $(this).val("请输入邮箱地址"); } }) $("#single").val("1号"); //val也能使select,checkbox,radio相应项被选中 $("#single option:eq(0)").attr("selected", true); //和上面效果一样 }) </script> </body> </html>