Skip to content

Instantly share code, notes, and snippets.

@jsakhil
Last active November 13, 2020 10:01
Show Gist options
  • Save jsakhil/90cae105b58a65014b8820d87d6e10d0 to your computer and use it in GitHub Desktop.
Save jsakhil/90cae105b58a65014b8820d87d6e10d0 to your computer and use it in GitHub Desktop.
Simple View More/ View Less Toggle for Content
$('.toggle').on('click', function(e){
e.preventDefault();
// Do Something
$(this).text($(this).text() == 'View More' ? 'View Less' : 'View More');
})
## Add class to body based on the URL – jQuery
var urlPath = window.location.pathname;
urlPath.match(/\/(.*?)(\+|$)/)[1].toLowerCase();
urlPath = urlPath.replace(/\//g, '-').slice(1);
urlPath = urlPath.replace(/\.[^/.]+$/, "");
$(document.body).addClass(urlPath);
$('body:not([class])').addClass('home');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment