1

I am using this code on the input element:

onmouseout="
$('#passwordhelp').text('');
$('#rpassword').attr('type', 'password')"
2
  • 3
    How about you try it out on a small html file? Commented Dec 17, 2011 at 22:46
  • possible duplicate of JQuery change type of input field Commented Dec 17, 2011 at 23:03

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

0

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...

2 Comments

Does jQuery actually go out of its way to check if prop is called as a setter on an input element with "type" as a key? Otherwise it won't work at least in IE.
Why is -1? This code works on latest versions of all browsers. There is an example and a warning for IE8 and below. So, the -1 caster, can you please explain yourself, why down vote?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.