JavaScript gets and changes the input Label Name property method _javascript Tips

Source: Internet
Author: User

The example in this article describes how JavaScript gets and changes the input label Name property. Share to everyone for your reference. The implementation methods are as follows:

<input name= "KK" ></input>

<script language= "JavaScript" >
// Here use getElementsByTagName to get all the input objects out,
//This is the key to this problem, using Bytagname instead of byname.
var list = document.getElementsByTagName ("input");
Follow the bad collection, including all input.
var inputlist = document.getelementsbyname ("KK");
Test
for (i=0;i<list.length;i++) {
//Here is the pop-up is ' KK ', of course, can also output other according to need.
//For example: List[i].id List[i].value and so on.
alert (list[i].name);//This is to modify this value
list[i].name = ' mm ';//Then the pop-up is ' mm '
alert (list[i].name);
}
</script>

I hope this article will help you with your JavaScript programming.

Related Article

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.