Suppose you have a list of checkbox like this:
<input value=”citizen” id=”citizen” onchange=”changeBrand(this.value)” name=”brand” type=”checkbox”>
<input value=”limit” id=”limit” onchange=”changeBrand(this.value)” name=”brand” type=”checkbox”>
<input value=”lorus” id=”lorus” onchange=”changeBrand(this.value)” name=”brand” type=”checkbox”>
<input value=”pulsar” id=”pulsar” onchange=”changeBrand(this.value)” name=”brand” type=”checkbox”>
Now use this script:
function changeBrand(brand){
$.each($(‘input:checkbox[name=”brand”]:checked’),function(index){
if($(this).val()!=brand){
$(this).prop(‘checked’,false);
}
});
}
Question and answer is powered by AnsPress.io