Skip to content

Instantly share code, notes, and snippets.

@graymic
Last active August 29, 2015 13:59
Show Gist options
  • Save graymic/19770c15e352fed2cbf2 to your computer and use it in GitHub Desktop.
Save graymic/19770c15e352fed2cbf2 to your computer and use it in GitHub Desktop.
JQuery based dom selector part 1.
(function (){
var newcss = ".mouseOn{background-color: #bcd5eb !important;outline: 2px solid #5166bb !important;}";
if ('\v'=='v') /* ie only */ {
document.createStyleSheet().cssText = newcss;
} else {
var tag = document.createElement('style');
tag.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(tag);
tag[ (typeof document.body.style.WebkitAppearance=='string') /* webkit only */ ? 'innerText' : 'innerHTML'] = newcss;
}
})();
prevElement = null;
document.addEventListener (
'mousemove',
function(e) {
var elem = e.target || e.srcElement;
if (prevElement!= null) {prevElement.classList.remove("mouseOn");}
elem.classList.add("mouseOn");
prevElement = elem;
},
true
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment