10form-attr.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <input type="button" value="获取值" /> <input type="button" value="设置值" /> <input type="text" name="" id="txt" /> <script> var ips = document.getElementsByTagName("input"); ips[0].onclick = function() { //alert(ips[2].value); //alert(ips[2].type); //alert(ips[2].disabled); // true ips[2].disabled = true; } ips[1].onclick = function() { ips[2].value = "阳光总在风雨后"; } /* 练习 页面加载完毕后 给所有的文本框赋值0、1、2、... 点击按钮的时候 获取所有文本框的值并使用|分割输出 */ </script> </body> </html>