Does javascript forbid changing the input type fro

2019-08-13 03:27发布

I am using this code on the input element:

onmouseout="
$('#passwordhelp').text('');
$('#rpassword').attr('type', 'password')"

2条回答
看我几分像从前
2楼-- · 2019-08-13 04:10

Are you using jQuery 1.6 or above? If so try .prop(). In your case like this (Example):

onmouseout="
$('#passwordhelp').text('');
$('#rpassword').prop('type', 'password')"

Though it won't work on IE8 and below.

IMHO you shouldn't use javascript and jQuery like this. Bind your events on .ready(). But of course it's your choice...

查看更多
虎瘦雄心在
3楼-- · 2019-08-13 04:12

You can't change the property type with jquery in the way you are attempting to do it. You're bumping into a browser issue:

See JQuery change type of input field

查看更多
登录 后发表回答