The reason that the whole page goes red as soon as you mouse over is that your code is matching a mouseover
event for the body
element. You can stop that from happening by only selecting children of body
.
$('body *').bind( //...
You'll hit performance problems on a page with a large number of elements, though since bind will attach a listener for every single matched element. Try taking a look into jQuery's event delegation api (.delegate()
, http://api.jquery.com/delegate/) which allows you to listen for events propagating up to a root element and works for mouse events as well.