views:

54

answers:

1

IE doesn't like the sharp symbol in the line below

jQuery(this).css('background-color','#' + jQuery(this).prev().val());

so I'm wondering if there is a different way to write the same without get error in IE?

+1  A: 

I've tested $(this).css('background-color', '#fff000'); in IE and it works fine so I don't think it's the sharp. It's how the color is either being constructed or an issue with quotes. Try:

var newColorTest1 = '#' + jQuery(this).prev().val();
alert(newColorTest1);
jQuery(this).css('background-color', newColorTest1);

What is shown in the alert box?

What is the value of jQuery(this).prev().val(); in your markup?

KP
Thanks for the answer. The problem was that the value was empty in some cases and that caused the error.if(jQuery(this).prev().val() != '')solved it.
Vasilis
No problem. Please consider marking as the answer if investigating `jQuery(this).prev().val();` assisted in finding the root cause...
KP