JavaScript中访问节点对象的方法有哪些如何使用
人气:0
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>
复制代码 代码如下:
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>
加载全部内容