I use Bootstrap switch plugin to make my checkboxes looks like switch buttons. I need to check if the checkbox is checked in jQuery. I Googled a lot and I tried some advice
Demo
Use .prop() instead of .attr()
.
.prop
returns - 'true' or 'false'. Use this:checked
is a pseudo slector. Or this.attr
returns - 'checked' or 'attribute undefined'. $('#uho').prop('checked')
if($('#uho').prop('checked')){
$.cookie("typpaliva", "Diesel");
}
else {
$.cookie("typpaliva", "Benzin");
}