I\'m making this little html app with a sidebar menu that pops up on click. It works fine except that it only starts to work after the second click. On the first click nothi
style.marginLeft is looking at your inline styles. As you haven't defined any inline style initially style.marginLeft is undefined.
style.marginLeft
To fix this, you could simply reverse your if/else statement:
if ( el.style.marginLeft=="0px" )