Last active
August 29, 2015 13:59
-
-
Save graymic/19770c15e352fed2cbf2 to your computer and use it in GitHub Desktop.
JQuery based dom selector part 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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