1

I am using this code on the input element:

onmouseout="
$('#passwordhelp').text('');
$('#rpassword').attr('type', 'password')"
Uğur Gümüşhan
  • 2,277
  • 4
  • 29
  • 59
  • 3
    How about you try it out on a small html file? – sinni800 Dec 17 '11 at 22:46
  • possible duplicate of [JQuery change type of input field](http://stackoverflow.com/questions/1544317/jquery-change-type-of-input-field) –  Dec 17 '11 at 23:03

2 Answers2

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

Community
  • 1
  • 1
jk.
  • 14,004
  • 3
  • 41
  • 55
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...

Emre Erkan
  • 8,282
  • 3
  • 46
  • 52
  • 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. – Esailija Dec 17 '11 at 22:57
  • 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? – Emre Erkan Dec 17 '11 at 23:10