Created
April 7, 2017 23:18
-
-
Save TaylorAckley/ca039eaaa902fb65c28ae9d9d2aa1f9d to your computer and use it in GitHub Desktop.
jquery show/hide with toggleable icons
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
//usage -- | |
//<i class="show-hide" data-elem="#hidden-content"></i> | |
//<div id="my-content" class="hidden">I'm hidden until the icon is clicked</div> | |
$(document).ready(function() { | |
$('.show-hide').on('click', function(e) { | |
e.preventDefault(); | |
var elem = $(this).attr('data-elem'); | |
$(elem).toggleClass('hidden'); | |
$(this).toggleClass('glyphicon-menu-down'); | |
$(this).toggleClass('glyphicon-menu-up'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment