How to mix this javascript toggle with window mouseup event

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>
			#showme { display: none; }
		<div id=button>Button</div>
		<div id=showme>
			I'm revealed!
			var d = document, w = window
			  , b = d.getElementById('button')
			  , a = d.getElementById('showme')

			b.addEventListener('click', function() {
				if ( !== 'block') = 'block';
				else = 'none';
			w.addEventListener('mouseup', function(e) { = 'none';

Thank you,

Never mind,

It needs window onload event to get this done. Not this one…

No it doesn’t. That event is almost never needed - I have come across exactly once where a script needed it and this isn’t that one.

Yes, you’re right. It doesn’t need it.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.