I have a list of events on a page. My end goal is to hide a purchase button (by adding a class to it) if the event has passed, using JQuery/Javascript. Each event has a 3 data attributes(month, day, year). I tried using the following method to cycle through an array:
var matches = document.querySelectorAll(".event-event");
var i = 0;
for (i = 0; i < matches.length; i++) {
var event = matches[i].getElementsByClassName('date');
var eventDate = event.getAttribute('data-date');
}
But it says that "getAttribute" is not a function, I've also tried ".attr" and it said the same thing.
matchesarray using document.querySelectorAll(), which means thatmatchesis an array of html elements, and html elements don't have month, day, and year attributes. Could you put a bare-bones version of your code on codepen.io or jsfiddle.net? It will be a lot easier to help you if we can see the html that your javascript with working with.