java學習

          java學習

           

          jquery文本框得到失去焦點


          <html>
          <head>
          <style type="text/css">
          body{
              font:normal 12px/17px Arial;
          }
          div{
              padding:2px;
          }
          input, textarea {
               width: 12em;
               border: 1px solid #888;
          }
          .focus {
               border: 1px solid #f00;
               background: #fcc;
          }
          </style>
          <!--   引入jQuery -->
          <script src="../scripts/jquery-1.3.1.js" type="text/javascript"></script>
          <script type="text/javascript">
              $(function(){
                  $(":input").focus(function(){
                        $(this).addClass("focus");
                        if($(this).val() ==this.defaultValue){  
                            $(this).val("");           
                        }
                  }).blur(function(){
                       $(this).removeClass("focus");
                       if ($(this).val() == '') {
                          $(this).val(this.defaultValue);
                       }
                  });
              })
              </script>


          </head>
          <body>
              <form action="" method="post" id="regForm">
                  <fieldset>
                      <legend>個人基本信息</legend>
                          <div>
                              <label  for="username">名稱:</label>
                              <input id="username" type="text" value="名稱" />
                          </div>
                          <div>
                              <label for="pass">密碼:</label>
                              <input id="pass" type="password" value="密碼" />
                          </div>
                          <div>
                              <label for="msg">詳細信息:</label>
                              <textarea id="msg" rows="2" cols="20">詳細信息</textarea>
                          </div>
                  </fieldset>
              </form>
          </body>
          </html>

          posted on 2013-03-20 09:30 楊軍威 閱讀(169) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 正蓝旗| 金堂县| 霍邱县| 隆林| 彩票| 景宁| 长春市| 久治县| 新泰市| 石嘴山市| 潼关县| 太湖县| 浠水县| 万载县| 闽侯县| 乡城县| 河池市| 赣榆县| 安达市| 娱乐| 霍城县| 黄冈市| 辽宁省| 平谷区| 蓝山县| 康平县| 丹棱县| 海林市| 筠连县| 枣强县| 韶关市| 会宁县| 郯城县| 昌吉市| 虹口区| 平昌县| 云南省| 玉树县| 屏东县| 康乐县| 民勤县|