JavaScript method for obtaining and changing the name attribute of the input tag, javascriptinput
This example describes how to obtain and change the name attribute of the input tag in JavaScript. Share it with you for your reference. The specific implementation method is as follows:
<Input name = "kk"> </input> <script language = "javascript"> // use getElementsByTagName to retrieve all input objects, // This is the key to this problem. Use ByTagName instead of ByName. Var list = document. getElementsByTagName ("input"); // contains all input values. Var inputList = document. getElementsByName ("kk"); // test for (I = 0; I <list. length; I ++) {// the pop-up here is 'kk '. Of course, you can also output something else as needed. // For example, list [I]. id; list [I]. value. Alert (list [I]. name); // This is to modify the value list [I]. name = 'mm'; // the pop-up is 'mm' alert (list [I]. name) ;}</script>
I hope this article will help you design javascript programs.