最近怠惰すぐるので、勉強がてらコードを残していこうかと。
input type=password の中身を表示する方法。
jQuery
// input typeを変更する function change_inputtype (id, value) { var target = '#' + id; var origin = $(target).get(0).type; $(target).get(0).type = value; } // #mode の変更を見つけたら $('#mode').change(function(){ // 対象のinput typeを変更 ($(this).prop('checked')) ? change_inputtype('pwarea', 'text') : change_inputtype('pwarea', 'password'); });
HTML
<form> <input type='password' id='pwarea'><br> <input type='checkbox' id='mode'>パスワードを表示 </form>