语法:
oElement = document . getElementById ( sID )
参数:
sID : 必选项。字符串(String)。
返回值:
oElement : 对象(Element)。
说明:
根据指定的 id 属性值得到对象。返回 id 属性值等于 sID 的第一个对象的引用。假如对应的为一组对象,则返回该组对象中的第一个。
如果无符合条件的对象,则返回 null 。
<script>
function rdl_doCheck(e){
var oCheckboxs=document.getElementsByTagName("input");
for (n=0;n<oCheckboxs.length;n++) oCheckboxs[n].checked=false;
with (document.all("oSelect")) {
var sValue=options[selectedIndex].value;
}
if (document.getElementById(sValue)!=null) document.getElementById(sValue).checked=true;
}
</script>
<input type=checkbox id=First><label for=First>我的ID是<b>First</b></label><br>
<input type=checkbox id=First><label for=First>我的ID也是<b>First</b></label><br>
<input type=checkbox id=Second><label for=Second>我的ID是<b>Second</b></label><br><br>
<select style="width:200px;" onchange="rdl_doCheck();" id=oSelect>
<option value="none" selected style="text-align:center;color:#333333;">--请选择--</option>
<option value="First">getElementById("First")</option>
<option value="Second">getElementById("Second")</option>
</select>
