0

How can I check element class name in JavaScript and how to change it?not classList

I've tried elementname.classList== "new_name"; to change it and it didn't change it and I want to be able to check the class name beyond just it's existence literally it's name, console.log(element.classList ) doesn't show it..

16th Jul 2023, 10:18 PM
Indiphile Menziwa
Indiphile Menziwa - avatar
4 Answers
+ 6
element.classList.contains("myStyle");
16th Jul 2023, 10:35 PM
JaScript
JaScript - avatar
+ 5
For this reason will be here each time repeated, please link your code with the question.
17th Jul 2023, 3:23 PM
JaScript
JaScript - avatar
+ 1
elementname.classList.add("new_name")
21st Jul 2023, 4:49 PM
Toni Isotalo
Toni Isotalo - avatar
0
Thanks but it didn't work
17th Jul 2023, 1:58 PM
Indiphile Menziwa
Indiphile Menziwa - avatar