Javascript Dynamic Change Imput type attribute _ basics

Source: Internet
Author: User

Javascript dynamically changes the Imput type attribute:

Code implementation:

<script type= "Text/javascript" >
  function Shoppw (thebox) {
    var ps = document.getElementById (' ps ');
    var pass = document.getElementById (' pass ');
    Ps.removechild (pass);
    var psimput = document.createelement ("INPUT");
    
    if (pass.type = = ' password ') {
      psimput.type = ' text ';
    } else {
      psimput.type = ' password ';
    }
    psimput.id = ' pass ';
    Psimput.name = "password";
    Psimput.maxlength= ";
    " Ps.appendchild (psimput);
  }
</script>

HTML code:

<TD class= "Label" > * <label for= "password" accesskey= "" > Login password:</label></td>
  <td > <div id= "PS" ><input type= "text" name= "password" maxlength= "" id= "pass"/></div> <input
   Name= "CheckBox2" type= "checkbox" Value= "true" checked= "Checked" id= "show" onclick= "SHOPPW (This)"/>
   For= "Show" accesskey= "" > Display </label></td>

Can dynamically change the type attribute value of a imput element at run time

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.