對于某些密碼,想要在手機(jī)上調(diào)出數(shù)字鍵盤,同時(shí)要隱藏文字。可結(jié)合type=tel和 text-security屬性達(dá)到目的。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>輸入密碼時(shí),調(diào)出手機(jī)的數(shù)字鍵盤</title>
<style>
input{
-webkit-text-security:disc;
text-security:disc; /*使用指定形狀代替文字顯示 circle圓圈 disc 圓形 square 正方形*/
}
</style>
</head>
<body>
<input type="tel" id="pass" />
<script>
window.onload = init;
function init(){
var x = document.getElementById("pass");
var style = window.getComputedStyle(x);
if(style.webkitTextSecurity){
//do nothing
}else{
x.setAttribute("type","password");
}
}
</script>
</body>
</html>我是有底線的
掃描二維碼手機(jī)查看該文章
文章引用:http://www.qingbaosc.com/news/webzhishi/1463.html




