Changing the type of an input field using jQuery (text -> password)

前端 未结 5 2230
天涯浪人
天涯浪人 2020-12-15 10:17

I am trying to change type of input, specifically after click into input change type=\"text\" to change=\"password\".

I don\'t know why, but I can\'

5条回答
  •  北海茫月
    2020-12-15 10:36

    If you're using jQuery 1.6, use .prop instead:

    $('input#id_reg_pass').removeAttr("type");
    $('input#id_reg_pass').prop('type', 'password');
    $(this).addClass('exampleText').val($(this).attr('title'));
    

    Demo: http://jsfiddle.net/z8Rj3/

提交回复
热议问题