不执行oneclick事件处理程序

时间:2012-06-01 13:03:35

标签: javascript

<html>
<head>
<title>Page title</title>
<script language="JavaScript" type="text/javascript">

        function oneClick ()
        {
         document.write ( "oneClick () executed." );
        }
</script>

</head>
<body>

<input id = "button1" type = "button" value = "click" oneclick = "oneClick ()" />

</body>
</html>

单击按钮后没有任何反应,我认为oneClick()没有执行!

3 个答案:

答案 0 :(得分:8)

oneclick事件处理程序名称应为onclick

答案 1 :(得分:4)

oneclick是onclick

<html> 
<head> 
<title>Page title</title> 
<script language="JavaScript" type="text/javascript"> 

        function oneClick () 
        { 
         document.write ( "oneClick () executed." ); 
        } 
</script> 

</head> 
<body> 

<input id = "button1" type = "button" value = "click" onclick = "oneClick ()" /> 

</body> 
</html>

答案 2 :(得分:3)

<input id = "button1" type = "button" value = "click" onclick = "oneClick();" />

现在应该可以正常工作了。 用onclick =“”

替换oneclick