Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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