There should be a special forum to discuss programming questions like this
Thanks in advance for any help or pointer.
So, I am trying to access the question-type div like this:
$(window).on('load', function() {
var questionType = document.getElementById("question-type");
var childNodes = questionType.childNodes;
if (questionType.className.localeCompare("reading") == 0){
questionType.style.backgroundImage = "none";
questionType.style.backgroundColor = "red";
} else if (questionType.className.localeCompare("meaning") == 0){
questionType.style.backgroundImage = "none";
questionType.style.backgroundColor = "blue";
}
});
But the className attribute of questionType is empty.
When I debug and put a breakpoint there, the function triggers before the page finalized its loading (the Wanikani revolving logo is still in the screen.
But if I continue after the breakpoint and inspect the element again, I find out this div has now the class I am trying to access:
I am guessing that WK has some kind of function that is adding this class to the question-type div after my function triggers.
Do you have any idea how could I make my script trigger after all changes to the DOM by WK are done?