Skip to content

Instantly share code, notes, and snippets.

@Kuzcoo
Created March 15, 2016 12:11
Show Gist options
  • Save Kuzcoo/426d12d5651e344d9db4 to your computer and use it in GitHub Desktop.
Save Kuzcoo/426d12d5651e344d9db4 to your computer and use it in GitHub Desktop.
(function () {
[].slice.call(document.querySelectorAll('span.read-more'))
.forEach(function (el, i) {
el.onclick = function (e) {
if (e.target.classList.contains('read-less')) { return; }
var content = this.querySelector('span.read-more-content');
var text = this.childNodes[0];
text.textContent = '';
content.style.display = 'inline';
this.querySelector('span.read-less').addEventListener('click', function fold (e) {
content.style.display = 'none';
text.textContent = '... Read more';
this.removeEventListener('click', fold);
});
};
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment