Mark and unmark checkbox independently

1

I have two checks, which work poorly, mark and unmark from the second check to the first one, I want them to work independently.

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/css/materialize.min.css" rel="stylesheet"/>


<input type="checkbox" id="myCheckbox" class="filled-in" /><label  for="myCheckbox"></label>
<input type="checkbox" id="myCheckbox" class="filled-in" /><label  for="myCheckbox"></label>
    
asked by hubman 23.03.2017 в 22:44
source

1 answer

3

It is that they have the same id and it should not be like that.

  • Each identifier is unique.
  • The label tag should be related to a single element or identifier.

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.0/css/materialize.min.css" rel="stylesheet"/>


<input type="checkbox" id="myCheckbox" class="filled-in" /><label  for="myCheckbox"></label>
<input type="checkbox" id="myCheckbox2" class="filled-in" /><label  for="myCheckbox2"></label>
    
answered by 23.03.2017 в 22:50