How can I do to select the value of the checkboxes below? I need to click on the checkbox to get the value of the checkbox clicked.
How can I do to select the value of the checkboxes below? I need to click on the checkbox to get the value of the checkbox clicked.
You can get the element using the jQuery click
function:
$("[type='checkbox']").click(function() {
// verifica se está selecionado
if($(this).is(':checked')){
console.log($(this).val())
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="form-group">
<div class="col-md-3">
<div class="checkbox">
<label class="">
<div>
<input type="checkbox" id="checktipo" value="fisica" name="checktipo[]" />
</div> Pessoa Física
</label>
</div>
</div>
<div class="col-md-3">
<div class="checkbox">
<label class="">
<div>
<input type="checkbox" id="checktipo" value="juridica" name="checktipo[]" />
</div> Pessoa Jurídica
</label>
</div>
</div>
<div class="col-md-3">
<div class="checkbox">
<label class="">
<div>
<input type="checkbox" id="checktipo" value="contato" name="checktipo[]" />
</div> Contato
</label>
</div>
</div>