2#txt1,#txt2{color:#CCC;border:1pxsolid#666;}3#pswd{display:none;border:1pxsolid#666;}4引用JS庫:1HTML:12地址:3

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

登錄事件,鼠標點擊輸入框隱藏默認值事件

系統 2104 0

CSS:

      
        1
      
      
        <style>


      
      
        2
      
      
            #txt1,#txt2
      
      {
      
         color
      
      :
      
        #CCC
      
      ;
      
         border
      
      :
      
        1px solid #666
      
      ;}


      
        3
      
      
            #pswd
      
      {
      
         display
      
      :
      
        none
      
      ;
      
        border
      
      :
      
        1px solid #666
      
      ;}


      
        4
      
      
        </style>        
      
    

引用JS庫:

      
        1
      
       <script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
    

HTML:

      
         1
      
      
        <
      
      
        form 
      
      
        id
      
      
        ="myform"
      
      
         action
      
      
        ="#"
      
      
        >
      
      
         2
      
      
            地址:


      
      
         3
      
      
        <
      
      
        input 
      
      
        type
      
      
        ="text"
      
      
         id
      
      
        ="txt1"
      
      
         value
      
      
        ="請輸入郵箱地址"
      
      
        />
      
      
         4
      
      
         5
      
      
        <
      
      
        br 
      
      
        />
      
      
         6
      
      
        <
      
      
        br 
      
      
        />
      
      
         密碼:


      
      
         7
      
      
        <
      
      
        input 
      
      
        type
      
      
        ="text"
      
      
         id
      
      
        ="txt2"
      
      
         value
      
      
        ="請輸入郵箱密碼"
      
      
        />
      
      
         8
      
      
        <
      
      
        input 
      
      
        type
      
      
        ="password"
      
      
         id
      
      
        ="pswd"
      
      
        />
      
      
         9
      
      
        10
      
      
        <
      
      
        br 
      
      
        />
      
      
        11
      
      
        <
      
      
        br 
      
      
        />
      
      
        12
      
      
        <
      
      
        input 
      
      
        type
      
      
        ="button"
      
      
         id
      
      
        ="btn"
      
      
         value
      
      
        ="登陸"
      
      
        />
      
      
        13
      
      
        </
      
      
        form
      
      
        >
      
    

JS代碼:

      
         1
      
      
        <
      
      
        script 
      
      
        type
      
      
        ="text/javascript"
      
      
         charset
      
      
        ="utf-8"
      
      
        >
      
      
         2
      
      
        dlsj(
      
      
        '
      
      
        #txt1
      
      
        '
      
      
        ,
      
      
        '
      
      
        請輸入郵箱地址
      
      
        '
      
      
        ,
      
      
        '
      
      
        #txt2
      
      
        '
      
      
        ,
      
      
        '
      
      
        #pswd
      
      
        '
      
      
        )   
      
      
        //
      
      
        調用
      
      
         3
      
      
         4
      
      
         5
      
      
        function
      
      
         dlsj (txt1,txt1_val,txt2,password) {


      
      
         6
      
      
        //
      
      
        郵箱地址輸入框獲取焦點
      
      
         7
      
      
                $(txt1).focus(
      
      
        function
      
      
        (){


      
      
         8
      
      
        var
      
      
         txt1_value
      
      
        =
      
      
        $(txt1).val();


      
      
         9
      
      
        if
      
      
        (txt1_value
      
      
        ==
      
      
        txt1_val){


      
      
        10
      
      
                $(
      
      
        this
      
      
        ).val(
      
      
        ''
      
      
        );


      
      
        11
      
      
                }


      
      
        12
      
      
            })


      
      
        13
      
      
        14
      
      
        //
      
      
        郵箱地址輸入框失去焦點
      
      
        15
      
      
            $(txt1).blur(
      
      
        function
      
      
        (){


      
      
        16
      
      
        var
      
      
         txt1_value
      
      
        =
      
      
        $(txt1).val();


      
      
        17
      
      
        if
      
      
        (txt1_value
      
      
        ==
      
      
        ""
      
      
        )


      
      
        18
      
      
                $(
      
      
        this
      
      
        ).val(txt1_val);{


      
      
        19
      
      
                }


      
      
        20
      
      
            })


      
      
        21
      
      
        var
      
      
         $txt2_obj
      
      
        =
      
      
        $(txt2);
      
      
        //
      
      
        獲取id為txt2的jquery對象
      
      
        22
      
      
        var
      
      
         $pswd_obj
      
      
        =
      
      
        $(password);
      
      
        //
      
      
        獲取id為txt2的jquery對象
      
      
        23
      
      
            $txt2_obj.focus(
      
      
        function
      
      
        (){


      
      
        24
      
      
                $pswd_obj.show().focus();
      
      
        //
      
      
        使密碼輸入框獲取焦點
      
      
        25
      
      
                $txt2_obj.hide();
      
      
        //
      
      
        隱藏文本輸入框
      
      
        26
      
      
        27
      
      
           })


      
      
        28
      
      
            $pswd_obj.blur(
      
      
        function
      
      
        (){


      
      
        29
      
      
        if
      
      
        ($pswd_obj.val()
      
      
        ==
      
      
        ''
      
      
        ){
      
      
        //
      
      
        密碼輸入框失去焦點后,若輸入框中沒有輸入字符時,則顯現文本輸入框
      
      
        30
      
      
                 $txt2_obj.show();


      
      
        31
      
      
                 $pswd_obj.hide();


      
      
        32
      
      
                 }


      
      
        33
      
      
        34
      
      
            })


      
      
        35
      
      
        }    


      
      
        36
      
      
        </
      
      
        script
      
      
        >
      
    

?

登錄事件,鼠標點擊輸入框隱藏默認值事件


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 禹州市| 满洲里市| 江北区| 南通市| 新龙县| 普定县| 临夏市| 淮阳县| 旬阳县| 安康市| 扎囊县| 库尔勒市| 桃江县| 土默特左旗| 安阳市| 庆云县| 万全县| 荔波县| 诸暨市| 安溪县| 开化县| 平果县| 泸水县| 油尖旺区| 洪泽县| 富源县| 泸溪县| 泽州县| 台中市| 永和县| 蒙自县| 青阳县| 阳山县| 南投市| 邹平县| 息烽县| 惠来县| 安西县| 修武县| 界首市| 内乡县|