gpt4 book ai didi

javascript - 无法使用 onclick 属性调用函数

转载 作者:行者123 更新时间:2023-12-03 05:53:27 26 4
gpt4 key购买 nike

为什么这不起作用?

html:

<html>
<head>
<title>test</title>
</head>
<body>
<button onclick="test21()">test</button>
</body>
</html>

JavaScript:

function test21(){
console.log("yey");
}

最佳答案

效果很好。这是一个 JSBin 来证明这一点。

<强> http://jsbin.com/luxesazibi/edit?html,output

很可能您还没有在 HTML 中加载脚本。你把 JavaScript 放在哪里?

关于javascript - 无法使用 onclick 属性调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40047680/

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