【发布时间】:2014-01-09 23:28:18
【问题描述】:
我正在学习 JavaScript,最近我一直在试验鼠标事件,试图了解它们是如何工作的。
<html>
<head>
<title>Mouse Events Example</title>
<script type="text/javascript">
function handleEvent(oEvent) {
var oTextbox = document.getElementById("txt1");
oTextbox.value += "\n" + oEvent.type;
if(oEvent.type=="click")
{
var iScreenX = oEvent.screenX;
var iScreenY = oEvent.screenY;
var b = "Clicked at "+iScreenX+" , "+iScreenY;
alert(b);
}
}
function handleEvent1(oEvent) {
// alert("Left Window");
}
</script>
</head>
<body>
<p>Use your mouse to click and double click the red square</p>
<div style="width: 100px; height: 100px; background-color: red"
onmouseover="handleEvent(event)"
onmouseout="handleEvent1(event)"
onmousedown="handleEvent(event)"
onmouseup="handleEvent(event)"
onclick="handleEvent(event)"
ondblclick="handleEvent(event)" id="div1"></div>
<p><textarea id="txt1" rows="15" cols="50"></textarea></p>
</body>
这是我一直试图理解的代码。任何人都可以帮我创建一个 HTML 表格,在点击表格的一个单元格时,用户会被告知他正在点击的单元格? 一直卡在上面,谢谢帮助。
【问题讨论】:
-
HTML 中没有表格
标签: javascript html events onclick