Just do $('body')
. That will assign a single handler to the <body>
element, and every descendant element (so, every element in the page) will bubble it's mouseover event up to that point. All you need to do inside the handler is check the originator of the event to find the exact element:
$('body').mouseover(function(e) {
var sender = e.target;
//sender is the element who was moused over
});
The key is not to do anything too intensive inside that handler, since it will basically be firing constantly as the user moves the mouse across your page. Best to start by checking the most restrictive conditions possible and return out of the method early as often as you can.