搜索框提示效果,输入框获取焦点,则原提示关键字消失,失去焦点,还原原关键字,当然是在没有输入用户关键字的前提下!
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>搜索框提示效果</title> <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" ></script> </head> <body> <p></p><br/> 鼠标点击输入框: <input id="name" type="text" value="keywords"/> <script type="text/javascript"> //$("#name").val(); $("#name").focus( function () {if($(this).val() == 'keywords') $(this).val("");}); $("#name").blur( function () {if($(this).val() == '') $(this).val("keywords");}); </script> </body> </html>
提示:你可以先修改部分代码再运行。
Related posts:
电子邮件地址不会被公开。 必填项已被标记为 *
名称 *
电子邮件 *
网站
评论
您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Anti-spam word: (Required)* To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.