cycling jQuery_Succinctly | Page 80

var $this = $(this); $this.clone(true).insertAfter(this); // Clone element and its events. $this.text('button').unbind('click'); // Change text, remove event. }); $('.clone').click(function () { var $this = $(this); $this.clone().insertAfter(this); // Clone element, but not its events. $this.text('link').unbind('click'); // Change text, remove event. }); })(jQuery); Getting X and Y coordinates of the mouse in the viewport By attaching a mousemove event to the entire page (document), you can retrieve the X and Y coordinates of the mouse pointer as it moves around inside in the viewport over the canvas. This is done by retrieving the pageY and pageX properties of the jQuery normalized event object. Sample: sample78.html Getting X and Y coordinates of the mouse relative to another element It is often necessary to get the X and Y coordinates of the mouse pointer relative to an element other than the viewport or entire document. This is usually done with ToolTips, where the ToolTip is shown relative to the location that the mouse is hovering. This can easily be accomplished by subtracting the offset of the relative element from the viewport’s X and Y mouse coordinates. 80