// optional var date = new Date(new Date().toDateString()); date.setDate(date.getDate() - 1); console.log(date) for (var el of document.getElementsByClassName('event')) { console.log(el) var d = Date.parse(el.getAttribute('data-timestamp')) if (d < date) { console.log("remove", d) el.remove() } }