you are here: codestackercodes [RSS]highlight an element

highlight an element

requires jquery.ui or jquery.color (https://github.com/jquery/jquery-color)

$.fn.highlight : function (highlightColor, duration) {
    var highlightBg = highlightColor || "#FFFF9C";
    var animateMs = duration || 2000;
    var originalBg = this.css("background-color");

    if (!originalBg || originalBg == highlightBg)
        originalBg = "#FFFFFF"; // default to white


    $(this).css("backgroundColor", highlightBg).animate({ backgroundColor: originalBg }, animateMs, null, function () { $(this).css("backgroundColor", originalBg);  });
}

Comments