js實(shí)現(xiàn)密碼框的點(diǎn)擊眼睛的顯示與隱藏
標(biāo)簽:
JavaScript
密码框的点击眼睛的显示与隐藏,图标引用是bootstrap中的fontawesome(复制整个 font-awesome 文件夹到您的项目中)还需要引入 <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>
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦