Posted on 1,九 | Posted by 姚 迎迎
搜索框提示效果,输入框获取焦点,则原提示关键字消失,失去焦点,还原原关键字,当然是在没有输入用户关键字的前提下!
<!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>
提示:你可以先修改部分代码再运行。
There are no comments yet
Log in to post a comment.
如果你举得我的文章对你有帮助,欢迎向我支付一小笔金钱作为回报。
数额无大小,这是我的收款主页http://me.alipay.com/yaoyingying
There are no comments yet
Log in to post a comment.