I want to get the value of the checkbox after it was clicked using javascript or jquery. Some checkbox was checked, some are not
<input type="checkbox" name="place[]" value="USA" checked>
<input type="checkbox" name="place[]" value="Canada">
<input type="checkbox" name="place[]" value="Japan" checked>
<input type="checkbox" name="place[]" value="Russia">
I want to get the value after the checkbox was clicked, whether it was checked or not.
Sample, If I've clicked : `<input type="checkbox" name="place[]" value="Russia">`
Result: Russia
Sample, If I've clicked : `<input type="checkbox" name="place[]" value="Japan">`
Result: Japan
How can I achieve this using javascript or jquery. Any help is appreciated. Thanks :)
UPDATED
I'm using bootstrap toggle buttons. Using below codes: It doesn't work.
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.0/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.0/js/bootstrap-toggle.min.js"></script>
<script>
$('#toggle-two').bootstrapToggle({
on: 'Enabled',
off: 'Disabled'
});
$('[name="place[]"]').change(function() {
console.log(this.value)
})
</script>
<input type="checkbox" name="place[]" value="USA" checked data-toggle="toggle" data-size="mini" data-onstyle="primary" data-offstyle="danger" data-on="Enabled" data-off="Disabled">
<input type="checkbox" name="place[]" value="Canada" data-toggle="toggle" data-size="mini" data-onstyle="primary" data-offstyle="danger" data-on="Enabled" data-off="Disabled">
<input type="checkbox" name="place[]" value="Japan" checked data-toggle="toggle" data-size="mini" data-onstyle="primary" data-offstyle="danger" data-on="Enabled" data-off="Disabled">
<input type="checkbox" name="place[]" value="Russia" data-toggle="toggle" data-size="mini" data-onstyle="primary" data-offstyle="danger" data-on="Enabled" data-off="Disabled">