Capture all click events with jQuery

A friend was after capturing any click event on a page and then checking the tag it was on/over. The great thing with jQuery is that you can get to this information with little effort. Below is a snippet of code which will dump the tag (in UPPERCASE) to the console.log.

view plain print about
1$(document).bind('click', function(e) {
2        console.log( e.toElement.tagName; )
3    });

If you want to know what else you can tap in to then change line 2 to console.log(e) and have a good explor around.

Posted: 23-Feb-2011

View: 2875

Permalink: here

Comments