0
ClassList.toggle().....is not working...plz answer me guys....
Everytime I use classlist in sololearn it gives me error like classlist.toggle is undefined....how to fix it??
14 odpowiedzi
+ 2
Here's an example of adding the event after html is loaded:
https://code.sololearn.com/W7Ppyku1Pmp4/?ref=app
+ 2
Can you please link your code (put it on sololearn playground)?
+ 1
it's classList, note the capital L
+ 1
Problem is with sololearn app @arpit.
0
Lisa i have done it....but still it's not working
0
Lisa its working fine on other ide but not on sololearn
0
@lisa yes sure
0
@lisahttps://code.sololearn.com/WzKxOR2j0gs7/?ref=app
Here is the code
0
It could be a loading order issue, that means for example the Javascript is loaded before the html is completely loaded and the js cannot find the html elements
There are multiple ways to fix this:
A) query the html element inside the function
function toggle() {
let nav = document.querySelector('.links');
nav.classList.toggle("active");
}
B) But all js code inside of window.onload and then add your toggle function via js to the html element (addEventListener...)
window.onload = function() {
// Here your js
// add toggle() to html element
}
0
Tech Giant ok bhai thanku
0
@lisa ok I'll try thanku so much
0
They just fix my comment section for me, am happy , now I can post thank you. You guys are awesome
0
How can add link in the center of playground
- 1
Bhjk