Hady
Hady

Reputation: 2674

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?

Upvotes: 73

Views: 46994

Answers (4)

Paolo Bergantino
Paolo Bergantino

Reputation: 488714

According to the documentation:

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

Upvotes: 142

Usman Younas
Usman Younas

Reputation: 1379

       $('.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.

Upvotes: 1

saschwarz
saschwarz

Reputation: 1237

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".

Upvotes: 3

Tomas Aschan
Tomas Aschan

Reputation: 60674

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

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

Upvotes: 18

Related Questions