首页 > 其他 > 详细

getElementByID,getElementsByName,getElementsByTagName

时间:2015-07-02 17:09:52      阅读:158      评论:0      收藏:0      [点我收藏+]
<input type="checkbox" name="hobby" id="hobby1">  音乐
  <input type="checkbox" name="hobby" id="hobby2">  登山
  <input type="checkbox" name="hobby" id="hobby3">  游泳
  <input type="checkbox" name="hobby" id="hobby4">  阅读
  <input type="checkbox" name="hobby" id="hobby5">  打球
  <input type="checkbox" name="hobby" id="hobby6">  跑步 
  <input type="button" value = "全选" id="button1">
  <input type="button" value = "全不选" id="button1">

1. document.getElementsByTagName("input"),结果为获取所有标签为input的元素,共8个。

2. document.getElementsByName("hobby"),结果为获取属性name="hobby"的元素,共6个。

3. document.getElementById("hobby6"),结果为获取属性id="hobby6"的元素,只有一个,"跑步"这个复选项。

getElementByID,getElementsByName,getElementsByTagName

原文:http://www.cnblogs.com/gide/p/4616432.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!