Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener("DOMContentLoaded", function() {
- // Create an object to keep track of datetime occurrences
- const datetimeOccurrences = {};
- // Select all elements with the class 'entry-date'
- const timeElements = document.querySelectorAll('.entry-date');
- // Loop through each element and count occurrences of each datetime
- timeElements.forEach(function(element) {
- const datetime = element.getAttribute('datetime');
- datetimeOccurrences[datetime] = (datetimeOccurrences[datetime] || 0) + 1;
- });
- // Reset the occurrence count to use for tracking while hiding
- const datetimeTrack = {};
- // Loop through again to set display style based on occurrences
- timeElements.forEach(function(element) {
- const datetime = element.getAttribute('datetime');
- datetimeTrack[datetime] = (datetimeTrack[datetime] || 0) + 1;
- if (datetimeOccurrences[datetime] > 1 && datetimeTrack[datetime] > 1) {
- element.style.display = 'none';
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment