I need to get the name
of the checked checkbox as soon as I click on one of the checkbox on the page. %% I already have, but I also need to get the value of value
.
Someone could help me or give me another alternative as I need to get the value of name
and name
at the same time as clicking.
$(document).ready(function () {
$('input[name="1117"]').click(function () {
selecionado('1117');
});
var selecionado = function (grupo) {
var result = $('input[name="' + grupo + '"]:checked');
if (result.length > 0) {
var contador = result.length + " selecionado(s)<br/>";
result.each(function () {
contador += $(this).val() + " "
});
$('#divFiltros').html(contador);
}
else {
$('#divFiltros').html("Nenhum selecionado");
}
};
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><divid="divFiltros"></div>
<form method="POST">
<legend>Marca</legend>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="6327" name="1117" value="6327">
<label for="">Samsung</label>
</div>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="6327" name="1117" value="6328">
<label for="">Motorola</label>
</div>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="6327" name="1117" value="6329">
<label for="">Sony</label>
</div>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="6327" name="1117" value="6330">
<label for="">LG</label>
</div>
<legend>Especificação</legend>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="450" name="1120" value="450">
<label for="450">4G</label>
</div>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="455" name="1120" value="455">
<label for="455">2 Chips</label>
</div>
<div class="checkbox checkbox-success">
<input class="styled marca" type="checkbox" id="461" name="1120" value="461">
<label for="461">Video 4K</label>
</div>
</form>