Using jQuery.css to get value in Internet Explorer

时间:2017-11-02 15:40:11

标签: jquery css internet-explorer internet-explorer-11

I am trying to set a variable to be the value of my div border-color property value

errorChartColorError = $('.col__item.error').css('border-color');

This works fine in Chrome but Internet Explorer 11 returns the variable as undefined

When I inspect the element in IE, I can see the border-color property and value

Do I need an IE hack?

1 个答案:

答案 0 :(得分:1)

边框颜色可以有多达四个值;这意味着您可以为每个边框(底部,左侧,顶部,右侧)设置不同的颜色。 更具体地说明你要回溯哪一个,所以:

$(".col__item.error").css("border-top-color");

$(".col__item.error").css("border-left-color");
等等......

应该做的伎俩