Thursday, October 30, 2008

[jQuery] Re: how can i check div background color

Each browser returns the background-color differently. Try the following

#mydiv { background: red; }

...

alert($("#mydiv").css("background-color"))

...

FF: rgb(255, 0, 0)
IE: red
Safari: rgb(255, 0, 0)
Opera: #ff0000

You'd have to normalize these values in order to do a comparison. The color plugin will help here:

http://plugins.jquery.com/project/color
http://plugins.jquery.com/files/jquery.color.js.txt

See the getRGB(color) function.

- Richard

On Thu, Oct 30, 2008 at 3:06 AM, salihriza <ismailsavran@gmail.com> wrote:

this is not wworking

    if($("#mydiv").css('background-color')=="red")

No comments: