


JavaScript method to get and change the name attribute of the input tag_javascript tips
May 16, 2016 pm 03:52 PMThe example in this article describes how to obtain and change the name attribute of the input tag using JavaScript. Share it with everyone for your reference. The specific implementation method is as follows:
<input name="kk"></input> <script language="javascript"> // 这里用getElementsByTagName把所有的input对象取出来, //这是这个问题的关键性的地方,用ByTagName而不是ByName。 var list = document.getElementsByTagName("input"); // 循坏这个集合,包括了所有的input。 var inputList = document.getElementsByName("kk"); //测试 for(i=0;i<list.length;i++){ // 这里弹出的就是'kk',当然也可以根据需要输出别的。 //比如:list[i].id; list[i].value等等。 alert(list[i].name);// 这是修改这个值 list[i].name = 'mm';// 这时弹出的就是'mm'了 alert(list[i].name); } </script>
I hope this article will be helpful to everyone’s JavaScript programming design.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement an online speech recognition system using WebSocket and JavaScript

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems

How to implement an online reservation system using WebSocket and JavaScript

How to use JavaScript and WebSocket to implement a real-time online ordering system

Simple JavaScript Tutorial: How to Get HTTP Status Code

JavaScript and WebSocket: Building an efficient real-time weather forecasting system

How to use insertBefore in javascript

How to get HTTP status code in JavaScript the easy way
