This is easy with CSS transitions:
JS:
$('li input:checked').click(function() { $(this).parent().parent().toggleClass("uncheckedBoxBGColor", 1000); });
CSS
.uncheckedBoxBGColor { background-color: orange; transition: background-color .3s; }
This will add effect whenever a class is included, but when it does not have this class, then there are no transitions. Instead, you can enable this transition for ALL <LI> elements, for example:
CSS
li { transition: background-color .3s; }
OR for all <INPUT> elements following the <LI><INPUT> combination:
li input { transition: background-color .3s; }
You get it.
source share