Last active
August 29, 2015 14:23
-
-
Save aviogreen/7c5d0089260ef923db00 to your computer and use it in GitHub Desktop.
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
/******************************************************* | |
:: Toggle Class | |
data-toggle="class" | |
data-class="" | |
data-target=".asd" | |
*******************************************************/ | |
$('[data-toggle=class]').each(function(index, el) { | |
$(this).click(function(){ | |
var target = null; | |
var the_class = $(this).data('class'); | |
if( $(this).data('target') == '' ){ | |
$(this).toggleClass(the_class); | |
} else if( $(this).data('target') == 'parent' ){ | |
$(this).parent().toggleClass( the_class ); | |
} else { | |
if( $($(this).data('target')).length ) | |
$($(this).data('target')).toggleClass( the_class ); | |
} | |
return false | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment