Hi guys,
I’ve got struck. I’m trying to do something like when you clicking on the hamburger button of this forum. It’s toggled a div, and it still works with the window mouseup event presented.
But my code here isn’t worked. What’s that I’ve done wrong.
<!DOCTYPE html>
<html>
<head>
<style>
#showme { display: none; }
</style>
</head>
<body>
<div id=button>Button</div>
<div id=showme>
I'm revealed!
</div>
<script>
var d = document, w = window
, b = d.getElementById('button')
, a = d.getElementById('showme')
;
b.addEventListener('click', function() {
if (a.style.display !== 'block')
a.style.display = 'block';
else
a.style.display = 'none';
});
w.addEventListener('mouseup', function(e) {
a.style.display = 'none';
});
</script>
</body>
</html>
Thank you,