Skip to content

Instantly share code, notes, and snippets.

@asllanmaciel
Created August 13, 2021 21:50
Show Gist options
  • Save asllanmaciel/18e951942e7a9e20e3d11c9c093b1ff4 to your computer and use it in GitHub Desktop.
Save asllanmaciel/18e951942e7a9e20e3d11c9c093b1ff4 to your computer and use it in GitHub Desktop.
Check All and Other with jQuery
$(document).ready(function() {
//See working in https://jsfiddle.net/asllanmaciel/qw5zj7an/4/
//check all checkboxes (array) except element ".outras"
$('input.all[name=tratamento_doencas\\[\\]]').click(function() {
$('input[name=tratamento_doencas\\[\\]]').not(this).not('.outras').prop('checked', this.checked);
});
//hide container
$('.tratamento_outras').hide();
//Toggle visibility
$('input.outras[name=tratamento_doencas\\[\\]]').change(function(ev) {
var t = ev.target
$('.tratamento_outras').toggle(500, function() {
$('input.outras[name=tratamento_doencas\\[\\]]').not(this).prop('checked', this.checked);
});
return false;
});
});
@asllanmaciel
Copy link
Author

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