简体   繁体   中英

How to give an alert whenever there is change in class Name

Just for some background, I'm a medical student who needs to take the board examination in order to receive my MD. Unfortunately, COVID-19 has cancelled testing dates for everyone since March. Now the testing centers that are open are only filling every other computer to maintain social distancing.

I am trying to build a Javascript that notifies me whenever there is an opening with Auto-refresh, but I am so poor at programming. Whenever a test date opens it the class changes from calInactive to calActive . Each class is also associated with an id and representing the date (ie id = 2020-10-24 )

setTimeout(function(){
    document.getElementById("masterPage_cphPageBody_btnGo").click();
                            
    if (document.getElementById("2020-10-24").hasClass("calActive"))
        alert("calActive");

}, 10000);end();

It works fine as it auto-refresh but it fails to alert me

Would love it if I could make this script doe better than alert, for example, to get me to the page direct and Alert function do not I have to be on the page to see it. in addition, this only check on the day only would love to know how to make it check more than one day.

在此处输入图片说明

Apologies for the long post.

I would actually search for all elements by the class. Then alert the date for which the class "calActive" is found.

var elementsCollection = document.getElementsByClassName("calActive");
for (const num of elementsCollection) {
  alert(num.id + " calActive")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM