js字符串函数:表单域name和js函数重名引起的问题来源: 发布时间:星期四, 2008年10月9日 浏览:247次 评论:0
无意中遇到这个问题,如下面的html代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script type="text/javascript"> function add(){ alert("call add method."); } function input(){ alert("call input method"); } </script> </head> <body> <form> <input type="button" name="add" value="添加" _disibledevent="alert(form1.add.value);" /> </form> </body> </html> 会发现事件执行的很好。 于是就想到了, 1.form是可以直接通过name来调用对应的form对象。 2.在同一form中,各个表单域又可以直接通过各自的name来调用各自的对象。 3.由于js中,函数也是对象,于是就引发了第一个代码段中的问题。 0
相关文章
读者评论
发表评论 |