Message from JavaScript discussions

November 2020

— Thing again. Does it really not!!!

— 

With a whip and a strong hand ofc🤤 any code-slave dreams to become a code-master, only freedom-coder does the task alone

— Company multiculture and agriculture

— Any idea why this doesn't work?

jQuery(document).ready(function () {

if(jQuery("#block-darkbgcontrol .dark-bg-control").hasClass("dark-bg") === true) {
jQuery("body").addClass("element-dark");
}

});

If I put alerts to display an 1 and a 0 as an if/else with that condition, they work, but the class isn't added.

Message permanent page

— Try debugger statements. They suck, but they do their job

— It does really not

— Ah yes, english.

— No visible result, putting it either before or after the addClass line.

— Tried toggleClass in place of addClass, but still no effect and no error.

The same line of code in another file works fine, so I'm quite at loss.

Message permanent page

— Now I changed it to "header" in place of "body" and it works, but I need it on body, how come that one gets ignored?

Message permanent page

— JQuery(document).ready(function () {

jQuery(document).ready(function () {

if(jQuery("#block-darkbgcontrol .dark-bg-control").hasClass("dark-bg") === true) {
jQuery("body").toggleClass("element-dark");
}

});

});

This works. Is it bad practice to repeat jQuery(document).ready() ?

Message permanent page

— 😅