Last active
September 8, 2023 10:47
-
-
Save aeruo/ea3276da5fe32852b768671427e9891b to your computer and use it in GitHub Desktop.
jQuery script for page handling, making it easier to contain multiple pages within one html file.
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
$(function(){ | |
//when a button is clicked | |
$('.page-button').on('click', function(){ | |
// Get the target page | |
var $target = $(this).attr('data-target'); | |
var $targetSelector = 'section#' + $target; | |
// Show target page | |
$($targetSelector).removeClass('page-hidden'); | |
$($targetSelector).addClass('page-visible'); | |
// Hide everything page | |
$('section.page:not(' + $targetSelector + ')').removeClass('page-visible'); | |
$('section.page:not(' + $targetSelector + ')').addClass('page-hidden'); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment