var issue in IE-8

40 Views Asked by At

While assigning a value for a variable, the variable is taking wrong value. The code is

var txtColor = $(".menu-item").css("background-color");

Where $(".menu-item").css("background-color"); represents pink color. But txtColor is taking as "transparent".

I'm seeing this issue only in IE-8.

Can anyone help me in fixing this issue.

Thanks in advance.

1

There are 1 best solutions below

0
Josh On

Question, is your CSS set up like this?

background: pink;

If so, try using $('.menu-item').css("background"); instead.

Old versions of IE will not properly cascade group definitions (like background) to the other settings. In modern browsers, defining background as "pink" will also set the background-color to "pink".