thanks to the suggestions I received here, I cleaned up my code and I'm now using pure jQuery. I made slight edits to a script I found here and I've got this:
window.onload = function(){
var tooltip = $( '<div id="tooltip">' ).appendTo( 'body' )[0];
$( 'img' ).
each(function () {
var pos = $( this ).position(),
top = pos.top,
left = pos.left,
width = $( this ).width(),
height = $( this ).height();
$( this ).
mousemove(function ( e ) {
var x = e.pageX - left,
y = e.pageY - top;
$( tooltip ).text( 'x = ' + x + ', y = ' + y ).css({
left: e.clientX + 10,
top: e.clientY + 10
}).show();
}).
mouseleave(function () {
$( tooltip ).hide();
});
});
};
I have a problem: I tried changing one line of my code to:
$( tooltip ).text( 'x = ' + x + '<br/> y = ' + y ).css({
but it does not work. Instead of breaking the line, I get this: