posts - 0,  comments - 19,  trackbacks - 0
          1
          <input name="user" type="text" id="user" size="50" onblur="if(this.value=='')

            {this.value='默認值';}" onclick="if(this.value='默認值')

            {this.value='';}" onfocus="if(this.value='默認值'){this.value='';}" value="默認值" />

          2
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
          <html>
           <head>
            <meta http-equiv="Content-Type" content="text/html; charsetGB2312" />
            <meta name="keywords" content="" />
            <meta name="description" content="" />
            <title>使文本框點擊時文字消失腳本</title>
           </head>
           <body>
            <input type="text" value="請輸入您的姓名" id="myinput" size="60" />
           </body>
          </html>
          <script language="JavaScript" type="text/javascript">
             function addListener(element,e,fn){
                  if(element.addEventListener){
                       element.addEventListener(e,fn,false);
                   } else {
                       element.attachEvent("on" + e,fn);
                    }
             }
             var myinput = document.getElementById("myinput");
             addListener(myinput,"click",function(){
              myinput.value = "";
             })
             addListener(myinput,"blur",function(){
              myinput.value = "請輸入您的姓名";
             })
          </script>

          3
          <!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" c />
          <title>點擊文本框,提示說明字消失!</title>
          <script type="text/javascript" src="http://www.veryhuo.com/uploads/common/js/jquery-1.4.2.min.js"></script>
          </head>
          <body>
          <script>
          $(document).ready(function(){
          $("TEXTAREA,input[focucmsg]") .each (function(){
          $(this).val($(this).attr("focucmsg"));
          $(this).val($(this).attr("focucmsg")).css("color","#979393");
          $(this).focus(function(){
          if($(this).val() == $(this).attr("focucmsg"))
          {
          $(this).val('');
          $(this).val('').css("color","#6b6969");
          }
          });
          $(this).blur(function(){
          if(!$(this).val()){
          $(this).val($(this).attr("focucmsg"));
          $(this).val($(this).attr("focucmsg")).css("color","#979393");
          }
          });
          });
          });
          </script>
          <input name="" type="text" focucmsg="請輸入關鍵字...?"  />
          <textarea  style="width:150px; height:50px;" name="" cols="" rows="" focucmsg="把自己的心情寫上來吧?"> </textarea>
          </body>
          </html>
          posted on 2012-07-31 11:03 canry Tong 閱讀(9924) 評論(2)  編輯  收藏 所屬分類: jsp

          FeedBack:
          # re: 點擊input框里面值置空
          2014-11-28 11:38 | 23424324
          1321231  回復  更多評論
            
          # re: 點擊input框里面值置空
          2016-08-05 09:17 | ttt
          aaa  回復  更多評論
            
          <2016年8月>
          31123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          留言簿

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          主站蜘蛛池模板: 得荣县| 海阳市| 乌兰县| 建阳市| 监利县| 庆云县| 兴安盟| 宝鸡市| 砚山县| 莱阳市| 开远市| 白沙| 沂南县| 宝鸡市| 岳普湖县| 尚志市| 海口市| 乳源| 新疆| 华亭县| 彩票| 和硕县| 乌鲁木齐市| 宁化县| 义乌市| 汤阴县| 鹰潭市| 杭锦后旗| 上杭县| 西乌| 白朗县| 翁源县| 东至县| 巴马| 泌阳县| 盘锦市| 岚皋县| 汾阳市| 阳谷县| 威信县| 嘉义县|