JavaScript中訪問節點對象的方法有哪些?
復制代碼 代碼如下:
var obj = document.getElementById('fdafda');
var obj = document.f1;
obj.method="post";
obj.action='Bb';
var obj = document.f1.userName;
var obj = document.forms[0].userName;
var obj = document.forms[0].elements[0];
var obj = document.f1.elements[0];
var obj = document.forms["f1"].elements["userName"];
var obj = document.forms[0].like;
for(var i=0;i<obj.length;i++)
{
var aa = obj[i];
if(aa.checked)
{
alert();
}
}
<form name="f1" action="AA">
<input type="text" name="userName" id="userName"/>
<input type="checkbox" name="like" value="sport"/>
<input type="checkbox" name="like" value="art"/>
<input type="checkbox" name="like" value="music"/>
</form>
<form name="f1" action="AA">
<input type="text" name="userName" id="userName"/>
<input type="checkbox" name="like" value="sport"/>
<input type="checkbox" name="like" value="art"/>
<input type="checkbox" name="like" value="music"/>
</form>
<form name="f1" action="AA">
<input type="text" name="userName" id="userName"/>
<input type="checkbox" name="like" value="sport"/>
<input type="checkbox" name="like" value="art"/>
<input type="checkbox" name="like" value="music"/>
</form>