首页 > Web开发 > 详细

jquery clear input default value

时间:2014-01-14 21:33:26      阅读:673      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
jquery 点击清除输入框的value值

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>jquery clear input default value</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body> <form id="form" action="" method="get"> <input type="text" name="First name" value="First name"/> <input type="text" name="Family name" value="Family name"/> <input type="text" name="Email" value="Email..."/> <input type="text" name="password" value="password..."/> <input type="text" name="location" value="City where you live"/> <input type="submit" name="sign up" value="Sign Up"/> </form> <script> $(#form).children(:text).focus(function(){ if(!this.initValue){ this.initValue = this.value; } if(this.value === this.initValue){ this.value = ‘‘; } }).blur(function(){ if(this.value === ‘‘ || this.value === null){ this.value = this.initValue; } }); </script> </body> </html>
bubuko.com,布布扣

jquery clear input default value

原文:http://www.cnblogs.com/cbhello/p/3513419.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!