Created
July 30, 2012 18:31
-
-
Save shakyShane/3208988 to your computer and use it in GitHub Desktop.
Helper method to show/hide a menu & update an Icon with Twitter Bootstrap
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
$('.action').on('click', function(){ | |
var icon = $(this).find('i'); | |
var toggleIcon = function (){ | |
var newIcon = (icon.hasClass('icon-plus')) ? 'icon-minus' : 'icon-plus' ; | |
icon.removeClass('icon-plus icon-minus'); | |
icon.addClass(newIcon); | |
} | |
toggleIcon(); | |
var action = $(this).data('action'); | |
var elem = $(this).data('elem'); | |
window[action](elem); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment