效果圖:

代碼如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="http://www.xipwang.cn/js/zepto.min.js"></script>
</head>
<body>
<div class="ui-password">
<input type="password" name="" class="passwords">
<button class="seepassword" >查看密碼</button>
</div>
<script type="text/javascript">
$(function(){
(function(){
$.fn.showpassWord = function () { //查看密碼
function Seepasswrod(elemnts) {
this.elemnts = elemnts;
this.init();
};
Seepasswrod.prototype = {
init: function () {
var m = this
this.shouEvent(m);
},
shouEvent: function (m) {
m.elemnts.on("tap click", function () {
var type = m.elemnts.parent().find(".passwords").attr("type");
if (type == "password") {
m.elemnts.parent().find(".passwords").attr("type", "text");
} else if (type == "text") {
m.elemnts.parent().find(".passwords").attr("type", "password");
}
});
},
};
return this.each(function () {
new Seepasswrod($(this))
});
};
})(Zepto);
$(".seepassword").showpassWord();
});
</script>
</body>
</html>
以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持億速云!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。