溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

js實(shí)現(xiàn)密碼框的點(diǎn)擊眼睛的顯示與隱藏

發(fā)布時(shí)間:2020-06-29 10:22:29 來源:網(wǎng)絡(luò) 閱讀:3183 作者:杏sunshine 欄目:web開發(fā)
密碼框的點(diǎn)擊眼睛的顯示與隱藏,圖標(biāo)引用是bootstrap中的fontawesome
(復(fù)制整個(gè) font-awesome 文件夾到您的項(xiàng)目中)
還需要引入
  <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="Font-Awesome/css/font-awesome.min.css">
<!doctype html>
<html>
    <head>
            <meta charset="utf-8">
            <title>密碼框</title>
            <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
            <link rel="stylesheet" type="text/css" href="Font-Awesome/css/font-awesome.min.css">
    </head>
<body>
    <div class="content">
        <div class="input_block">
            <i class="fa fa-eye" onclick="hideShowPsw()" id="eye"></i>
            <input type="password" id="password" placeholder="密碼"/>
        </div>
    </div>
   <script type="text/javascript">
            var eye = document.getElementById("eye");
            var password = document.getElementById("password");
            //隱藏text block,顯示password block
            function hideShowPsw(){
                    if (password.type == "password") {
                            password.type = "text";
                            eye.className='fa fa-eye-slash'
                    }else {
                            password.type = "password";
                            eye.className='fa fa-eye'
                    }
                }
    </script>
</body>
</html>
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI