javascript - Q. javascript. why don't play 'onclick'?
问题描述
why don't play onclick="catch()" ? I don't understand.
<script>
function catch () {
alert("safsf");
}
</script>
...
<body>
<td><img src="media/strawberry.png" onclick="catch()"></td>
</body>
解决方案
catch
is a reserved keyword in javascript. Therefore we can't use it in our function/variable names. Try changing the name of the function:
function error(){
alert(2);
}
<div onclick="error()" class="test">click me 2</div>
推荐阅读
- sql-server - 单个行上的 WHERE 子句
- flutter - Flutter 图像选择器 Web
- php - 如何使用 Laravel 集成 CCAvenue
- c# - 从多个内部元素 od XML 文件中获取名称属性值到 C#
- vbscript - 验证 vbScript 参数名称
- python - 使用 Biopython 时:NameError: name 'pubmed_id' is not defined 即使之前已经定义过?
- python - 套接字编程:客户端在向服务器发送 3 条消息后停止响应
- android - 获取改造异步调用的结果
- php - 数据库中有两个不同的表我想按日期或时间顺序从一个表中获取数据?
- javascript - Canvas 圆弧函数的含义