JQuery - Binding Data
Show the location of where the click happened eg 0,0
by aaronk85
HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Click or double click here.</p>
<span></span>
</body>
</html>
CSS
p { background:yellow; font-weight:bold; cursor:pointer;
padding:5px; }
p.over { background: #ccc; }
span { color:red; }
JavaScript
$("p").bind("click", function(event){
var str = "( " + event.pageX + ", " + event.pageY + " )";
$("span").text("Click happened! " + str);
});
$("p").bind("dblclick", function(){
$("span").text("Double-click happened in " + this.nodeName);
});
$("p").bind("mouseenter mouseleave", function(event){
$(this).toggleClass("over");
});