Toggle Text | CSS-Tricks

PHOTO EMBED

Mon Jun 22 2020 13:00:11 GMT+0000 (Coordinated Universal Time)

Saved by @Amna #jquery

$("#more-less-options-button").click(function() {
     var txt = $("#extra-options").is(':visible') ? 'more options' : 'less options';
     $("#more-less-options-button").text(txt);
     $("#extra-options").slideToggle();
});
content_copyCOPY

Let’s say you have a link to show more options which expands a list of options. It’s says “more options”. It’s easy to toggle those options with .toggle() or .slideToggle(), but the text remains the same. To toggle the text too…

https://css-tricks.com/snippets/jquery/toggle-text/