onload = function () { alert(document.getElementById(‘Button0‘).value); var buttonArr = document.getElementsByName(‘n1‘); for (var i = 0; i < buttonArr.length; i++) { alert(buttonArr[i].value); } var button = document.getElementsByTagName("input"); for (var i = 0; i < button.length; i++) { alert(button[i].value); } };
获取页面元素三种方式: getElementById
getElementsByName
getElementsByTagName
时间: 2024-11-21 03:49:02