Thanks for the question. Actually, if I had plenty of elements on my webpage, still my JS file would be of the same length. Here in the JS is just adding the class dark-mode to the body tag when the button with the class myBtn is pressed. If more element is there our CSS file will increase. For eg: if I add a div tag with background color blue by default, and want to change it to yellow in the dark-mode, we just had to add the code below in the CSS file:
.dark-mode>div{background:yellow;}
May this example help. :-)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the question. Actually, if I had plenty of elements on my webpage, still my JS file would be of the same length. Here in the JS is just adding the class dark-mode to the
body
tag when the button with the class myBtn is pressed. If more element is there our CSS file will increase. For eg: if I add adiv
tag with background color blue by default, and want to change it to yellow in the dark-mode, we just had to add the code below in the CSS file:May this example help. :-)