I am trying to create a jQuery event that fires a second event. The first event is a click on the emoji identifier, which refers to the image. The second is the mousemove event, which moves the image around the page. The third event stops this event when a mouse click occurs again anywhere on the page body and places the image in this absolute position. I was able to get the second and third events, but I can not get the first event to work with the second. Here is what I have used so far for jQuery:
var mouseTracker = function(event) { console.log(event.pageX, event.pageY, !!event.which) $('#emoji').css('top', event.pageY); $('#emoji').css('bottom', event.pageY); $('#emoji').css('left', event.pageX); $('#emoji').css('right', event.pageX); } var begin = function() { $('body').on('mousemove', mouseTracker); $('body').css('cursor', 'none'); } var stop = function() { $('body').off('mousemove', mouseTracker); $('#emoji').css('postion', 'absolute') $('body').css('cursor', 'default'); } $('#emoji').on('click', begin); $('body').on('click', stop);`
source share