Skip to content

Instantly share code, notes, and snippets.

@sonichandni
Last active November 23, 2021 06:20
Show Gist options
  • Save sonichandni/cece3f628cbba9b3893aa10039871435 to your computer and use it in GitHub Desktop.
Save sonichandni/cece3f628cbba9b3893aa10039871435 to your computer and use it in GitHub Desktop.
Unselect other multiple choices when the user selects none or anything related to none like none of above or none option
$(document).on('click', '.checkboxClass', function () {
if($(this).val().includes("none")) {
cr_val = $(this).val();
ch_nm = $(this).attr('name');
$("input[name='"+ch_nm+"'][value!='"+cr_val+"']").prop("checked",false);
} else {
ch_nm = $(this).attr('name');
$("input[name='"+ch_nm+"']").each( function() {
console.log($(this).val());
if($(this).val().includes("none")) {
$(this).prop("checked", false)
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment