Increase visible text on click.
I am trying to increase the words that are visible when user clicks on the link. It does not seem to listen to the click command. How can I achieve this? My code looks like below.
- $(document).ready(function () {
- var $wordCount = 12;
- $("h2").on("click", function () {
- var $wordCount = 112;
- });
- function getWords(str) {
- return str.split(/\s+/).slice(0, $wordCount).join(" ");
- }
- var str = $(".hider").text();
- $(".showHere").text(getWords(str));
- });