+ 1
Why won't Jquery test the CSS properly?
I'm testing to see if the hiddenMenu left css is -100%, if so set to 0%. And do the opposite if it's 0%, ultimately making a sidenav. For some reason when testing document.querySelector(".hiddenMenu").style.left == "-100%", the if statement won't trigger. How can I test left css? Sorry about the readability on mobile, line wrap did something bad for once https://code.sololearn.com/W2IzqJBd8sQ3/?ref=app
2 odpowiedzi
+ 2
You can't access css style that way ,it will return nothing unless it's set to some value,to get css value you need to use
getComputedStyle(document.querySelector(".hiddenmenu")).left which returns value in pixels which for -100% is -360px
through jQuery you can get it much easily,
menu.css("left"));
+ 1
Abhay Thanks, never heard of that function before