模拟淘宝搜索框

<html>
    <head>
        <title>
         测试输入框
        </title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
        <script type="text/javascript">
		   $(function(){
           $("#q").focus(function() {
		    $("label[for=q]").hide();
           });

           $("#q").blur(function () {
		   //  alert($("#q").val());
          if ("" == $("#q").val()) {
          $("label[for=q]").show();
          } 
         });
		 });
        </script>
    </head>
    
    <body>
        <form>
            <span>模拟搜索框:
                 <label for="q" style="visibility: visible; color: #666; position: absolute; left: 120px; top: 18px; ">输入您想搜索的宝贝</label>
                 <input id="q" type="text" autocomplete="off" title="搜索宝贝" name="q" size="25" />
            </span>
        </form>
    </body>
</html>

 

你可能感兴趣的:(JavaScript,jquery)