日期:2014-05-16  浏览次数:20314 次

问个基础问题
<form   name= "form1 ">
<input   type= "button "   name= "a "   value= "a "   onclick= "hanshu() ">
</form>

如果我在hanshu()   里写this     就是把这个input标签传进了函数   可是我想把form传进去     请问应该怎么写?       不写document.form1   可不可以?   谢谢谢谢回答!

------解决方案--------------------
<form name= "form1 ">
<input type= "button " name= "a " value= "a " onclick= "hanshu(this.form); ">
</form>
function hanshu(obj){
obj是form1
}
------解决方案--------------------
楼上回答正确,一下为验证:
<script type=text/javascript>
function hanshu(obj)
{
alert(obj.nodeName);
}
</script>
<form name= "form1 ">
<input type= "button " name= "a " value= "a " onclick= "hanshu(this.form) ">
</form>
------解决方案--------------------
[个人意见,仅供参考]
document.getElementById( 'YourFormId ');
------解决方案--------------------
function fangfa(){
var obj = document.form1;
}