JSFiddle - React, Tailwind, and code Playground

by sarathsprakash

HTML

<input type="checkbox" id="chk"><label for="chk" style="text-decoration:underline">Add to cart</label>

JavaScript

$("#chk").click(function () {

    if ($(this).is(":checked")) {
        $(this).next().fadeOut("slow", function () {
            $("#chk").next().text("Added");
        }).fadeIn("slow");

    } else {

        $(this).next().fadeOut("slow", function () {
            $("#chk").next().text("Add to cart");
        }).fadeIn("slow");
    }

});