O
O
olegmorales132018-04-02 09:44:26
css
olegmorales13, 2018-04-02 09:44:26

Why do checkboxes work incorrectly?

I have checkboxes:

<label><input type="checkbox"> 1  </label>					          
<label><input type="checkbox"> 2 </label>					          
<label><input type="checkbox"> 3  </label>				          
<label><input type="checkbox"> 4 </label>


The label has the following handler:
function(e) {
  if ($(this).find('input').prop('checked')) {
    $(this).find('input').prop('checked', false);
  } else {
    $(this).find('input').prop('checked', true);
  }
}


For some reason, when you click on the label, the CHECKBOX is ticked, and when you click on the checkbox itself, nothing happens. Another handler is attached to the label, but I don’t think it interferes in any way

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Medvedev, 2018-04-02
@balamyt92

Why do you need this handler? When you click on the label, the associated checkbox is automatically checked without it, but this action is performed twice (when you click on the checkbox) and nothing happens.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question