0

whats wrong with this code

var menuBtn = document.getElementByID('menuBtn'); var sideNav = document.getElementByID('sideNav'); sideNav.style.right = "-250px"; menuBtn.onrclick = function () { if (sideNav.style.right == "-250px") { sideNav.style.right = "0"; } else{ sideNav.style.right = "-250px"; } }

28th Jun 2020, 6:20 AM
Anish Ghimire
Anish Ghimire - avatar
3 Réponses
+ 3
You should link to your saved code in the playground instead. Anyway, if you're running it from the playground and you have the code in the JS tab, you'll most likely need to wrap the code in a window.onload = function () { ... code here ... } Also, onrclick is misspelled.
28th Jun 2020, 6:31 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
menuBtn.onclick = function () { instead menuBtn.onrclick = function () {
28th Jun 2020, 7:12 AM
JaScript
JaScript - avatar
0
No iam running it on vs code ChaoticDawg
28th Jun 2020, 6:33 AM
Anish Ghimire
Anish Ghimire - avatar