Skip to content

Instantly share code, notes, and snippets.

@easikoglu
Last active April 26, 2016 20:17
Show Gist options
  • Save easikoglu/54cac6d40e4918d1f80b to your computer and use it in GitHub Desktop.
Save easikoglu/54cac6d40e4918d1f80b to your computer and use it in GitHub Desktop.
Inspect element mauseover
function mouseOverColor(evt)
{
var element = evt.target; // not IE
// set the border around the element
element.style.borderWidth = '2px';
element.style.borderStyle = 'solid';
element.style.borderColor = '#f00';
}
function mouseOutColorRemove(evt)
{
evt.target.style.borderStyle = 'none';
}
function mouseOnClick(evt)
{
var selection = evt.target.innerHTML;
console.log('Element is: ' + evt.target.toString() + '\n\nSelection is:\n\n' + selection);
return false;
}
document.addEventListener("mouseover", mouseOverColor, true);
document.addEventListener("mouseout", mouseOutColorRemove, true);
document.addEventListener("click", mouseOnClick, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment