I am trying to achieve a simple task using jQuery. I have a checkbox inside a box, and I want to toggle a class on the box with a transition when the checkbox is checked. However, my code is not working as expected. Here is what I have:
$(document).ready(function(){
if ($('.onoffcheck').is(':checked')) {
$(".panel-success").toggleClass("panel-off2");
} else {
$(".panel-off").toggleClass("panel-success");
}
});