I need to change one message generated by the calendar to another, I mean the message “There are no upcoming events.”. I tried with the below JS, but it didn’t work. Please help – how can I change the content of this message?
document.addEventListener("DOMContentLoaded", function () {
const updateEventMessage = () => {
const noEventsMessage = document.querySelector(
".tribe-events-c-messages__message-list-item[data-key='0']"
);if (noEventsMessage && noEventsMessage.textContent.trim() === "There are no upcoming events.") {
noEventsMessage.textContent = "My NEW text.";
}
};
const observer = new MutationObserver(function (mutationsList) {
mutationsList.forEach(function (mutation) {
if (mutation.type === "childList") {
updateEventMessage();
}
});
});
const targetNode = document.querySelector(".tribe-events-c-messages__message-list");
if (targetNode) {
observer.observe(targetNode, {
childList: true,
subtree: true
});
}
updateEventMessage();
});