求教 document.getElementById 的用法
的有关信息介绍如下:1、getElementById作用:一般页面里ID是唯一的,用于准备定为一个元素 语法: document.getElementById(id) 参数:id :必选项为字符串(String) 返回值:对象; 返回相同id对象中的第一个,按在页面中出现的次序,如果无符合条件的对象,则返回 nullexample:document.getElementById("id1").value;2、getElementsByName作用:按元素的名称查找,返回一个同名元素的数组语法: document.getElementsByName(name)参数:name :必选项为字符串(String)返回值:数组对象; 如果无符合条件的对象,则返回空数组,按在页面中出现的次序example:document.getElementsByName("name1")[0].value; document.getElementsByName("name1")[1].value; 3、getElementsByTagName作用:按HTML标签名查询,返回一个相同标签元素的数组语法: object.getElementsByTagName(tagname) object可以是document或event.srcElement.parentElement等参数:tagname:必选项为字符串(String),根据HTML标签检索。返回值:数组对象; 如果无符合条件的对象,则返回空数组,按在页面中出现的次序example:document.getElementsByTagName("p")[0].childNodes[0].nodeValue; document.getElementsByTagName("p")[1].childNodes[0].nodeValue