I can’t change the text in one calendar message
-
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();
});
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.