gpt4 book ai didi

javascript - Onclick 功能在 IE 11 中不起作用

转载 作者:行者123 更新时间:2023-12-01 02:23:13 26 4
gpt4 key购买 nike

我正在尝试在 HTML 中添加提交函数,并使用我的函数引用 js 文件。该代码在 Chrome 中运行成功,但在 IE11 中运行失败。错误消息是“submitFunc(event) 未定义”。谁能帮我解决这个问题吗?我已经尽力了。 TT

function submitFunc(event) {
console.log("Hey what are you looking for? ")
}
<html>
<div>
<input class="btn btn-primary" type="submit" value="submit" onclick="submitFunc(event)">
</div>
</html>
<script type="text/javascript" src="/static/js/main.js"></script>

最佳答案

可能是你的<script>标记在 <html>...</html> 之外堵塞。尝试将其移至 <head>...</head>第一个 <html> 之后的部分标签。

关于javascript - Onclick 功能在 IE 11 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49039397/

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