开发者

jQuery: What is the problem with this jQuery.css() call?

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?


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜