标签:style blog color ar java for sp div on
<input type="button" name="haha" value="按钮" id="btn" /> <input type="button" name="haha" value="按钮" id="Button1" /> <input type="text" name="haha" value="按钮" id="Button2" />
<script type="text/javascript"> //1,根据获取单个该元素 var btnObj = document.getElementById(‘btn‘); //2,根据name获取所有name属性一样的元素 var objs = document.getElementsByName(‘haha‘); for (var i = 0; i < objs.length; i++) { alert(objs[i].id);//每个元素的id } //3,根据标签,获取元素 var inputs = document.getElementsByTagName(‘input‘); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == ‘text‘) { inputs[i].value = ‘哈哈哈我是文本框‘; } } </script>
标签:style blog color ar java for sp div on
原文地址:http://www.cnblogs.com/valiant1882331/p/4071144.html