mouseevent - jQuery - How to return a value from jQuery function (not an ajax call) -
i have following jquery
function
jquery(document).ready(function(){ jquery(document).mousemove(function(e){ alert(e.pagex +', '+ e.pagey); }); });
i want return these 2 values (e.pagex
, e.pagey
) in function. how can this?
i tried this
function getmouseposition(e) { var tt = jquery(document).ready(function(){ jquery(document).mousemove(function(e){ return (e.pagex +', '+ e.pagey); }); }); alert(tt); }
getmouseposition(e)
called function.
can in this?
any appreciated.
edit:
below scenario: 1. click on element on web page. 2. opens popup menu , opens jquery dialog box. 2. there image/icon in opened jquery dialog box, when click on icon, furthermore opens popup menu. when click on icon in jquery dialog return negative value first time. second time return positive value.
try making handler , giving variable store results. can manipulate variable like
var position = {}, // store position here mousemovehandler = function(e){ position.pagex = e.pagex; position.pagey = e.pagey; myfunction(); // have call function after position results populated }; // function handles results var myfunction = function(){ alert(position.pagex+', '+position.pagey); }; // give handler mousemove jquery(document).ready(function(){ jquery("#target").mousemove(mousemovehandler); }); // every time mousemove triggered, results in 'position' variable
an example -> http://jsfiddle.net/exvkg/
Comments
Post a Comment