简体   繁体   English

如何在班级名称发生变化时发出警报

[英]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.不幸的是,自 3 月以来,COVID-19 已取消对所有人的测试日期。 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.我正在尝试构建一个 Javascript,每当有自动刷新打开时都会通知我,但我在编程方面很差。 Whenever a test date opens it the class changes from calInactive to calActive .每当测试日期打开它时,类就会从calInactive更改为calActive Each class is also associated with an id and representing the date (ie id = 2020-10-24 )每个类还与一个 id 相关联并表示日期(即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.然后提醒发现类“calActive”的日期。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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