查看密码
作者:chrispy
(function ( $ ) {
$.fn.togglePassword = function( options ) {
var s = $.extend( $.fn.togglePassword.defaults, options ),
input = $( this );
$( s.el ).bind( s.ev, function() {
"password" == $( input ).attr( "type" ) ?
$( input ).attr( "type", "text" ) :
$( input ).attr( "type", "password" );
});
};
$.fn.togglePassword.defaults = {
ev: "click"
};
}( jQuery ));
<input type="password" class="passVal">
<input type="button" class="lookPass">
$(function(){
$('#password').togglePassword({
el: '#togglePassword'
});
$('.passVal').togglePassword({
el: '.lookPass'
});
});