Created
March 16, 2015 22:35
-
-
Save micflan/42f0710c3cbbd63e1c12 to your computer and use it in GitHub Desktop.
Simple jQuery reveal-on-click checkbox
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
// | |
// <input type="checkbox" class="checkboxReveals" data-reveal="#someContainer" /> | |
// <div id="someContainer" style="display: none;"> ... </div> | |
// | |
$(function() { | |
var checkboxReveal = function(checkbox) { | |
var target = $(checkbox.data('reveal')); | |
if(checkbox.is(":checked")) { | |
target.slideDown(); | |
} else { | |
target.slideUp(); | |
} | |
}; | |
$('.checkboxReveals').each(function() { | |
checkboxReveal($(this)); | |
}); | |
$('.checkboxReveals').change(function() { | |
checkboxReveal($(this)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment