Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change html input type by JS?

How to do this through the tag itself change type from text to password

<input type='text' name='pass'  /> 

Is it possible to insert JS inside the input tag itself to change type='text' to type='password'?

like image 731
user1150271 Avatar asked Feb 01 '12 10:02

user1150271


People also ask

How do you change the input in HTML?

<input type="reset">

How do you change an element in JavaScript?

First, select the DOM element that you want to replace. Then, create a new element. Finally, select the parent element of the target element and replace the target element by the new element using the replaceChild() method.


1 Answers

Try:

<input id="hybrid" type="text" name="password" />  <script type="text/javascript">     document.getElementById('hybrid').type = 'password'; </script> 
like image 54
deed02392 Avatar answered Sep 22 '22 16:09

deed02392