Answer the question
In order to leave comments, you need to log in
How in internet explorer 8, in the input field, change the type attribute from password to text and vice versa?
I'm trying to make a button, by clicking on which, the entered password will be hidden or shown.
In normal browsers via attr('type',"text") и attr('type',"password")
everything works fine. Now I need to get this to work in IE 8
Answer the question
In order to leave comments, you need to log in
The field type cannot be changed for security purposes. You can only replace it with a copy:
$passwordField = $('.your-selector');
attribites = {
id: $passwordField.attr('id'),
type: $passwordField.attr('type') === 'password' ? 'text' : 'password',
name: $passwordField.attr('name'),
value: $passwordField.attr('value'),
class: $passwordField.attr('class'),
};
$passwordField.replaceWith($('<input/>', attribites));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question