chris-ELM
4/6/2014 - 6:59 PM

Text switch. Switches text on click using data element From https://news.layervault.com/stories/19629-favorite-code-snippets

Text switch. Switches text on click using data element

From https://news.layervault.com/stories/19629-favorite-code-snippets

$('.js-textEdit').click(function() {
  var oldText = $(this).text();
  var newText = $(this).data('text');
  $(this).text(newText).data('text', oldText);
});

<span class="js-textEdit" data-text="Show less">Show more</span>