gpt4 book ai didi

javascript - html js - onclick 不工作

转载 作者:行者123 更新时间:2023-11-30 13:34:08 25 4
gpt4 key购买 nike

我通常不使用 onclick,但是当我遇到这个问题时,我打算为一个完全不同的目的做一些调试编码。我完全失明了吗,或者为什么这不起作用?

<html>
<head>

<script type="text/javascript">
function click()
{
alert("hey");
}
</script>

</head>

<body>

<!-- Will not work in any browser -->
<input type="button" onclick="click()" value="click me" />

<!-- Will not work in IE -->
<a href="#" onclick="click()">click me</a>

<!-- Works in all -->
<input type="button" onclick="alert('hey')" value="click me" />
<a href="#" onclick="alert('hey')">click me</a>

</body>
</html>

最佳答案

“click”不是一个 JS 函数的好名字,尤其是 IE

写下你的函数的名字,让我们都开心 =D

关于javascript - html js - onclick 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5583106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com