• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript I think I learned a lesson

Lesson: Don't insert all the questions into one topic, regardless of how difficult or interesting it looks.

I have been trying to edit classes of elements, but each time, I always get
Code:
Uncaught TypeError: Cannot read properties of undefined (reading 'toggle')
on 'remove', 'delete' and 'toggle'.

W3Schools is in this case not helping at all. (probably even counterproductive to the search of a solution)
 

Antero360

King Coder
Staff Team
Security Analyst
Lesson: Don't insert all the questions into one topic, regardless of how difficult or interesting it looks.

I have been trying to edit classes of elements, but each time, I always get
Code:
Uncaught TypeError: Cannot read properties of undefined (reading 'toggle')
on 'remove', 'delete' and 'toggle'.

W3Schools is in this case not helping at all. (probably even counterproductive to the search of a solution)
This is because what you are trying to access either a) hasn't loaded in yet, or b) you may be using another identifier.
whenever you get something like this, save the element you are trying to access into a variable, and before you attempt to use any calls on it, log it to console, and inspect the result.
Code:
//if you're using jquery
var myElement = $('#myEl');

//vanila js
var myElement = document.querySelector('#myEl');
var myElement = document.getElementById('myEl');

console.log(myElement);

On a side note: :) there's no issue with you posting multiple questions in a single post lol. Best advice though, is that if you are going to do that, make sure that all questions are related to an extent. That way, it stays on topic, and clean, so that neither you or anyone responding gets confused
 
Top