开发者

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

开发者 https://www.devze.com 2022-12-23 10:04 出处:网络
IE doesn\'t like the sharp symbol in the line below jQuery(this).css(\'background-color\',\'#\' + jQuery(this).prev().val());

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

精彩评论

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

关注公众号