Skip to content

Instantly share code, notes, and snippets.

@dcs619
Last active December 12, 2015 07:09
Show Gist options
  • Select an option

  • Save dcs619/4734665 to your computer and use it in GitHub Desktop.

Select an option

Save dcs619/4734665 to your computer and use it in GitHub Desktop.
Javascript function to toggle div dispaly
<script type="text/javascript">
$(document).ready(function () {
var checkboxChange = function () {
$(this).parent().next('div').toggle();
}
$('.togglePanel').on('change', checkboxChange);
});
</script>
//////// within markup
<label class="checkbox">
<input type="checkbox" class="togglePanel" id="cbxCreateAcct" /> Save My Information
</label>
<div id="grpCreateAcct" style="display: none">
... elements
</div>
@dcs619

dcs619 commented Feb 12, 2013

Copy link
Copy Markdown
Author

Added one-time click event:

onclick="javascript: $('#grpCreateAcct').toggle()"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment