Skip to content

Instantly share code, notes, and snippets.

@davidmerfield
Created April 25, 2019 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmerfield/0c45c49a7b6a625e71aa68a509d2a9f8 to your computer and use it in GitHub Desktop.
Save davidmerfield/0c45c49a7b6a625e71aa68a509d2a9f8 to your computer and use it in GitHub Desktop.
Will hide
// CSS selector which will match all the HTML elements containing a date
var dateSelector = '.date';
// Iterate over all the dates, hiding each date identical to its immediate predeccessor
Array.from(document.querySelectorAll(dateSelector)).reduce(function(previousDate, el){
if (previousDate && previousDate === el.innerHTML)
el.style.display='none';
return el.innerHTML;
}, '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment