通過更改input的password和text類型即可實現
1 //點擊函數,獲取dom,判斷更改屬性。 2 show(){ 3 let input=document.getElementById("inputId"); 4 if(input.type=="password"){ 5 input.type='text'; 6 }else{ 7 input.type='password'; 8 } 9 }
jq的話,直接用toggle,從而可以簡化if.. else條件語句!
通過更改input的password和text類型即可實現
1 //點擊函數,獲取dom,判斷更改屬性。 2 show(){ 3 let input=document.getElementById("inputId"); 4 if(input.type=="password"){ 5 input.type='text'; 6 }else{ 7 input.type='password'; 8 } 9 }
jq的話,直接用toggle,從而可以簡化if.. else條件語句!
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。