Change highlight color

jQuery's highlight method will highlight any div with a yellow background.

How do I specify what color to use instead of yellow for highlight?


Solution 1:

According to the documentation:

$(this).effect("highlight", {color: 'blue'}, 3000);

Solution 2:

$("div").click(function () {
    $(this).effect("highlight", { color: "#ff0000" }, 3000);
});

will highlight in red. It's all in the documentation.

Solution 3:

FWIW I found that IE8 would give an error in jQuery 1.7.2 usingeffect("highlight",...) when the current color of the element was specified as text or when the highlight color was specified as text (i.e. "blue") instead of in hex notation: "#ff0000".

Solution 4:

       $('.divID').live('mouseover mouseout', function (event) {
        if (event.type == 'mouseover') {
            // do something on mouseover
          $(this).css({ "background-color": YOURCOLOR, "opacity": ".50" });

        }
        else {
            // do something on mouseout
             $(this).css("opacity", "100");

        }
      });

This will give the nice hover effect with opacity looks.