Skip to content
Advertisement

Condition: input:checked with the same class

I would like to have a little help on an enigma that I have. I have a button that changes according to the number of input:checked but I would like to add a condition which is: select of the checkboxes of the same class.

for example can I have 2 or more input.

JavaScript

I can’t use attribute name or value. it is not possible to modify the inputs.

the condition:

JavaScript

I try with

JavaScript

I don’t know if I’m going the right way or if I’m complicating the code but a little help would be welcome. For the moment my attempts have been unsuccessful.

Advertisement

Answer

The following function will reference the first checkbox that’s checked className and enable each checkbox that has said className whilst disabling all other checkboxes. Details are commented in Snippet.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement