wrkbrs

[jQuery] input 태그 타입 패스워드로 변경 본문

jQuery

[jQuery] input 태그 타입 패스워드로 변경

zcarc 2019. 1. 11. 04:57

This question already has an answer here:

I want to change the input type to password when I click on it. I tried this:

<input name="pin" id="cp_serv" type="text" class="pin_v" value="Insert PIN Please" onclick="this.value='';$(this).attr('type','password');"/>

I tried to use the jQuery function attr to change this on the click event, but nothing is happening.

Is this the right way to do it or is this possible?



This will work

$('input').on('click', function () {
   $(this).attr('type', 'password'); 
});

jsfiddle

Update

For IE read accepted answer for this post.



https://stackoverflow.com/questions/18539052/transform-input-type-text-to-password

'jQuery' 카테고리의 다른 글

jQuery 정리 2  (0) 2019.01.12
jQuery 정리 1  (0) 2019.01.12
[jQuery] .each() (jQuery 반복문)  (0) 2019.01.11
[jQuery] 셀렉터(Selector) 사용하기 / 특정 단어 셀렉터  (0) 2019.01.11
[jQuery] .attr() / .prop()의 차이  (0) 2019.01.10