虽然我现在对这些语言了解很多,例如数组和函数,但我有一个基本的问题就是运行这个JavaScript,这里是代码:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type="submit" value="submit" onclick="click()" />
<script>
function click() {
alert("hey");
}
</script>
</body>
</html>
&#13;
答案 0 :(得分:1)
您遇到此问题:javascript function name cannot set as click?
您可以通过将函数名称更改为function myClick
<head>
</head>
<body>
<input type="submit" value="submit" onclick="myClick()" />
<script>
function myClick() {
alert("hey");
}
</script>
</body>
</html>
答案 1 :(得分:0)
function submit() {
alert("hey"); }
&#13;
<html>
<head>
</head>
<body>
<input type="submit" value="submit" onclick="submit()" />
</body>
</html>
&#13;