Created
December 11, 2012 19:57
-
-
Save tmcw/4261587 to your computer and use it in GitHub Desktop.
Click Events, lol, wut
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<style> | |
div { | |
margin:5px; | |
width:900px; | |
height:100px; | |
font:30px 'Comic Sans'; | |
color:#fff; | |
background:magenta; | |
position:absolute; | |
} | |
#wut { | |
background:cyan; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='wut'>wut</div> | |
<div id='lol'>lol</div> | |
<script> | |
// fully-featured jquery replacement mobile ready blah blah | |
function $(x) { | |
var d = (x[0] !== '.') ? document.getElementById(x) : document.getElementsByClassName(x.slice(1)); | |
d.on = function(x, c) { | |
if (d.length) for (var i = 0; i < d.length; i++) d[i].addEventListener(x, c); | |
else d.addEventListener(x, c); | |
return d; | |
} | |
return d; | |
} | |
function say(e) { alert('clicked') } | |
$('lol').on('mousedown', function() { | |
$('wut').style.zIndex=2; | |
}).on('click', say); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment