JQuery Color: Do Color Animations with jQuery

时间:2022-06-28 14:27:54

JQuery color, a jQuery plugin that adds the ability to do color animations to jQuery. Demo effect:

JQuery Color: Do Color Animations with jQuery

Sample code:

<style>
    div {
        position: absolute;
        background-color: #fff;
        width: 90px;
        height: 90px;
        border: solid 1px #000;
    }

    #testElement1 {
        left: 50px;
    }

    #testElement2 {
        left: 200px;
    }
</style>

<div id="testElement1">
</div>

<div id="testElement2">
</div>
<script src="~/Scripts/jquery-2.1.4.min.js"></script>
<script src="~/Scripts/jquery.color-2.1.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#testElement1").animate({ backgroundColor: "#abcdef" }, 800)
                .animate({ backgroundColor: "#fff" }, 800)
                .animate({ backgroundColor: "#abcdef" }, 800)
                .animate({ backgroundColor: "#fff" }, 800);

            $("#testElement2").animate({ backgroundColor: "#969696" }, 800)
                .animate({ backgroundColor: "#fff" }, 800)
                .animate({ backgroundColor: "#969696" }, 800)
                .animate({ backgroundColor: "#fff" }, 800);
        });
    </script>

You can also fork the github: https://github.com/jquery/jquery-color