Created
March 25, 2014 16:04
-
-
Save jlittlejohn/9765051 to your computer and use it in GitHub Desktop.
JS: Toggle Buttons Utility Function
This file contains hidden or 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( $ ){ | |
$.fn.toggleButtons = function() { | |
this.on('click', function(e) { | |
e.preventDefault(); | |
var targetID = $(this).data('id'); | |
if( $(targetID).hasClass('hide') ) { | |
$(targetID).toggleClass('hide'); | |
} else { | |
$(targetID).toggle(); | |
} | |
}); | |
return this; | |
}; | |
})( jQuery ); | |
$('a.reveal').toggleButtons(); | |
// <a class="reveal" data-id="#example"></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment