<!DOCTYPE html> <html> <head lang="zh"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8" /> <meta content="yes" name="apple-mobile-web-app-capable"/> <meta content="yes" name="apple-touch-fullscreen"/> <meta content="telephone=no" name="format-detection"/> <meta content="black" name="apple-mobile-web-app-status-bar-style"> <meta content="#ffffff" name="msapplication-TileColor" /> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> <title>采销商品基本信息</title> <link rel="stylesheet" href="css/index.css"/> </head> <body> <div class="pox"> 佛得角粉丝卡<span>jkladja</span>放到那送到哪 </div> <div class="pox-1"> 佛得角粉丝卡<span>jkladja</span>放到那送到哪<input class="pox-text" type="text" name="" value="hello"> </div> <script type="text/javascript" src="./js/jquery.js"></script> <script type="text/javascript"> $("input").focus(function(){ var aa=$(this).val(); var bb=$(this)[0].defaultValue; if(aa==bb){ $(this).val(""); } }); $("input").blur(function(){ var aa=$(this).val(); var bb=$(this)[0].defaultValue; if(aa==""){ $(this).val(bb); } }); </script> </body> </html>
注意的是defaultValue是js原生态的属性!要使用$(this)[0].defaultVaue