Change highlight color

JqueryJquery Ui

Jquery Problem Overview


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?

Jquery Solutions


Solution 1 - Jquery

According to the documentation:

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

Solution 2 - Jquery

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

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

Solution 3 - Jquery

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 - Jquery

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHadyView Question on Stackoverflow
Solution 1 - JqueryPaolo BergantinoView Answer on Stackoverflow
Solution 2 - JqueryTomas AschanView Answer on Stackoverflow
Solution 3 - JquerysaschwarzView Answer on Stackoverflow
Solution 4 - JqueryUsman YounasView Answer on Stackoverflow