javascript - Getting the value of current checkbox from a group of checkboxes with same class name -
i'm trying value of current checkbox group of checkboxes same class name below. jquery code seems not acting out accordingly. me out this?
html
<input type="checkbox" class="checkbox1" value="test"/><br /> <input type="checkbox" class="checkbox1" value="test2"/> <br /> <input type="checkbox" class="checkbox1" value="test3"/>
js
$(document).ready(function() { //set initial state. $('.checkbox1').click(function() { if ($(this).is(':checked')) { console.log($('.checkbox1').val()); } }); });
any appreciated!
thank you.
is:
$('.checkbox1:checked').val()
what looking for?
Comments
Post a Comment