请JavaScript高手指点,button按钮的onclick事件一直报错
我写的源代码如下:<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><script...
我写的源代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="javascript">
function accept(){
alert("ok");
}
</script>
<body>
<form action="" method="post">
<input type="radio" id="1" value="2" />2
<input type="radio" id="2" value="3" />3
<input type="radio" id="3" value="4" />4
<input type="button" value="确认" onClick="return accept();"/>
</form>
</body>
</html>
点击button按钮后一直报对象不支持此操作,请各位看看我哪写错了。 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="javascript">
function accept(){
alert("ok");
}
</script>
<body>
<form action="" method="post">
<input type="radio" id="1" value="2" />2
<input type="radio" id="2" value="3" />3
<input type="radio" id="3" value="4" />4
<input type="button" value="确认" onClick="return accept();"/>
</form>
</body>
</html>
点击button按钮后一直报对象不支持此操作,请各位看看我哪写错了。 展开
2个回答
展开全部
方法名是关键字,换个就好.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="javascript">
function accept1(){
alert("ok");
}
</script>
<body>
<form action="" method="post">
<input type="radio" id="1" value="2" />2
<input type="radio" id="2" value="3" />3
<input type="radio" id="3" value="4" />4
<input type="button" value="确认" onClick="return accept1();"/>
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="javascript">
function accept1(){
alert("ok");
}
</script>
<body>
<form action="" method="post">
<input type="radio" id="1" value="2" />2
<input type="radio" id="2" value="3" />3
<input type="radio" id="3" value="4" />4
<input type="button" value="确认" onClick="return accept1();"/>
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询