Tuesday, May 7, 2019

javascript - Getting the value of current checkbox from a group of checkboxes with same class name



I'm trying to get the value of the current checkbox from a group of checkboxes with the same class name as below. However the jquery code seems to not be acting out accordingly. Could anyone help me out with this?



http://jsfiddle.net/m8fdc/2/



HTML








JS



$(document).ready(function() {
//set initial state.

$('.checkbox1').click(function() {
if ($(this).is(':checked')) {
console.log($('.checkbox1').val());
}
});
});


Any help would be greatly appreciated!



Thank you.


Answer



Is:



$('.checkbox1:checked').val()


What you are looking for?


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...