How to obtain and change the name attribute of the input tag in JavaScript
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:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<Input name = "kk"> </input> <Script language = "javascript"> // GetElementsByTagName is used to retrieve all input objects, // This is the key to this problem. Use ByTagName instead of ByName. Var list = document. getElementsByTagName ("input "); // This set 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 as needed. // For example, list [I]. id; list [I]. value. Alert (list [I]. name); // This is to modify this 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.