Total members 11889 |It is currently Fri Mar 29, 2024 10:50 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Get mouse position , mouse click position.
javascript code
<html>
<head>
<title>Get Mouse Position- Mouse Over</title>

<!--
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
Note you can download the JQuery package instead of using Google version. -->
<script src="jquery-1.8.3.js"></script>
<script>
$(document).ready(function(){
var startMousePos = { x: -1, y: -1 };
var endMousePos = { x: -1, y: -1 };
var MousePos={ x: -1, y: -1 };

$(document).bind('mousemove',function(e){
$("div#info2").text(" Mouse pageX: " + e.pageX + ", MousepageY: " + e.pageY);
MousePos.x=e.pageX;
MousePos.y = e.pageY;

});
$('p#text').mousedown(function(){
jQuery(function(event) {

startMousePos.x = MousePos.x;
startMousePos.y = MousePos.y;
$("div#infox").html("<br/>startMousePos.x=("+startMousePos.x
+")startMousePos.y=("+startMousePos.y+")");



});
});
$('p#text').mouseup(function(){
jQuery(function(event) {
endMousePos.x = MousePos.x;
endMousePos.y = MousePos.y;
$("div#infoy").html(",endMousePos.x=("+endMousePos.x
+")endMousePos.y=("+endMousePos.y+")");

});
});
});
$('p#text').mouseover(function() {
$('#info2').append('<div>Handler for .mouseover() called.</div>');
});

</script>
</head>
<body>
<p id="text"> Mouse Over on this text , press on this text </p>


<div id="infox" ></div><br>
<div id="infoy" ></div><br>
<div id="info2" ></div>
</body>
</html>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Get Mouse Position using JQuery
 Mouse position in C++     -  
 Change background position when mouse over     -  
 Get the position of HTML element using JQuery     -  
 X and Y background position     -  
 static vs fixed div position     -  
 setting div background position     -  
 ORACLE/ SQL DBA this is a CTH position. No H1B’s     -  
 right bottom background image position     -  
 Set position of background image in pixels     -  
 Slide automatically-specific speed to a determined position     -  



Topic Tags

JQuery Mouse
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com