dimanche 17 janvier 2016

Check if a certain group of checkboxes is checked

I have a total of ten checkboxes on my page, the last five of them are special. And if anyone of them are checked a want to show a message on the page that extra costs will apply to those products. They all have different name and value. Since I can't have the same id on all the checkboxes I am really stuck.

This was the last thing I tested but I cant get to work for all 5 checkboxes.

var check;
$("#test-with-is").on("click", function(){
    check = $("#mycheckbox").is(":checked");
    if(check) {
        alert("Checkbox is checked.");
    } else {
        alert("Checkbox is unchecked.");
    }
}); 

Any clue what I am doing wrong?




Aucun commentaire:

Enregistrer un commentaire