Created
March 15, 2016 12:11
-
-
Save Kuzcoo/426d12d5651e344d9db4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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