javascript - 未捕获的 ReferenceError:sakla 未在 HTMLImageElement.onclick 中定义
问题描述
我是 JavaScript 新手,我遇到了这个错误。下面是我的代码:
<html>
<head>
<script type="text/javascript" src="jquery-3.4.1.min.js">
function hide() {
// some actions
}
</script>
</head>
<body>
<img id="myImgId" src="http://www.google.com/images/srpr/logo4w.png" onclick="hide()" style="position:absolute;opacity:0.5;left:50%;top:50%;width:50px;height:50px;margin-left:-25px;margin-top:-25px;z-index:100;"/>
</body>
可能是什么问题呢?
解决方案
试试下面的代码
<html>
<head>
<script type="text/javascript" src="jquery-3.4.1.min.js" />
<script>
function hide() {
// some actions
}
</script>
</head>
<body>
<img id="myImgId" src="http://www.google.com/images/srpr/logo4w.png" onclick="hide()" style="position:absolute;opacity:0.5;left:50%;top:50%;width:50px;height:50px;margin-left:-25px;margin-top:-25px;z-index:100;"/>
</body>
推荐阅读
- node.js - 如何使用带有 https 的 socket.io
- android - 使用风味在 AppGallery 和 Google Play 上发布应用
- python - 使用自定义开始/结束日期显示多年的数据 - datetime, matplotlib
- big-o - 我的代码在大 O 表示法中的复杂性是多少
- python - QIcon 的 PyQt5 “Ghost”出现在 QComboBox 的 QLineEdit 中
- c - Swift - 将转义闭包传递给 C API 回调
- ionic-framework - NFC Mifare Ultralight 伪造响应数据
- arrays - 如何在Excel中混合动态数组和常量数组
- c# - DataGrid 文本框 DataTrigger 条件未按预期工作
- python - python3:在“datetime.timedelta”和“str”的实例之间不支持