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"; } }
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.
+ 1
menuBtn.onclick = function () { instead menuBtn.onrclick = function () {
0
No iam running it on vs code ChaoticDawg