2
From the current checkbox selection, how to mark the next checkbox element and disable all other.
I have this code, which when dialing a checkbox consequently all the others are deactivated, but I need that when dialing a checkbox automatically it marks the next checkbox and deactivates the others.
I tried with next() but did not succeed
$(document).ready(function(){
$('#formNine input:checkbox').click(function(){
var $inputs = $('#formNine input:checkbox')
if($(this).is(':checked')){
$inputs.not(this).prop('disabled',true); // <-- disable all but checked one
}else{
$inputs.prop('disabled',false); // <--
}
});
});
You need to explain what you want to do better. Want to check the next checkbox or the one that was clicked on? Want to do
disabled
? This also depends on the HTML structure. You can put an example of your HTML here?– Sergio
Its code, adapted, gives this: http://jsfiddle.net/zLu25z45/ which is basically what a radio button does... I want to help but I don’t understand what it wants.
– Sergio
for example I have a <label><input type="checkbox"><input type="checkbox"><input type="checkbox"></label> if I mark the first I want the first and the second to be marked, if I mark the second that is marked the second and third, whenever I mark a checkbox, You know what I mean? I think now I can express myself better
– Pablo Campina