Skip to content

Instantly share code, notes, and snippets.

@jonschr
Created January 28, 2020 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonschr/127a9bc27af05f6da5fad720359819b5 to your computer and use it in GitHub Desktop.
Save jonschr/127a9bc27af05f6da5fad720359819b5 to your computer and use it in GitHub Desktop.
toggle the legend
<script>
jQuery(document).ready(function( $ ) {
//* vars for easier reference later
var togglelegendbutton = $( '.legendtoggle' );
var legenddiv = $( '.organizerDiv' );
var tabcontent = $( '.tabcontent' );
//* this function does everything needed to toggle it
function togglethelegend() {
togglelegendbutton.toggleClass( 'activestate' );
legenddiv.toggleClass( 'activestate' );
tabcontent.hide();
}
//* if someone clicks on the legend, toggle it
togglelegendbutton.on( "click", togglethelegend );
//* on desktop only, go ahead and turn on the legend by default
if ($(window).width() > 600) {
togglethelegend();
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment