Last active
May 22, 2019 01:14
-
-
Save walterdavis/b53174947ca0c007d91c6e03144a9204 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
// find all the divs with the class name 'more', and hide them | |
$$('div.more').invoke('hide'); | |
// "listen" for clicks on any link with the class name 'more', and respond... | |
$(document).on('click', 'a.more', function(evt, elm){ | |
// first, stop any normal reaction, like scrolling back to the top of the browser window | |
evt.stop(); | |
// starting from the link that was clicked, look up to its containing element... | |
// then select the following div with the class name 'more', and if it's hidden, show it, or vice-versa | |
elm.up().next('div.more').toggle(); | |
// toggle the text inside the link that was clicked | |
elm.update((elm.innerText == 'more' ? 'less' : 'more')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment