Skip to content

Instantly share code, notes, and snippets.

@ravinggenius
Forked from austintaylor/event_inspector.js
Created April 12, 2011 19:47
Show Gist options
  • Save ravinggenius/916237 to your computer and use it in GitHub Desktop.
Save ravinggenius/916237 to your computer and use it in GitHub Desktop.
var eventColors = {
mouseover: 'red',
mouseout: 'blue',
click: 'yellow'
}
var highlight = function(event) {
Event.stop(event);
element = Event.element(event);
Element.setStyle(element, {backgroundColor: eventColors[event.type]});
setTimeout(Element.setStyle.bind(null, element, {backgroundColor: ''}), 200);
}
Event.observe(window, 'load', function() {
Event.observe(document.body, 'mouseover', highlight.bindAsEventListener());
Event.observe(document.body, 'mouseout', highlight.bindAsEventListener());
Event.observe(document.body, 'click', highlight.bindAsEventListener());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment