动态切换'background-image'在IE中不起作用

and*_*uha 3 css jquery

我正在用下面的jquery位动态切换div的背景图像.在FF中运行得很好,但在IE中却没有.有什么想法吗?如果css属性发生变化,IE是否重新加载图像?任何指针将不胜感激.

$(function(){
   $('.header').each(function(){
      $(this).hover(function(){
         $('#headertab').css('background-image','url(/tab_'+$(this).attr('href').split('path=')[1]+'.gif');
      });
   });
}); 
Run Code Online (Sandbox Code Playgroud)

Mat*_*chu 6

尝试设置backgroundImage而不是background-image.

CSS属性,通过Javascript访问时,传统上使用camelCase而不是破折号,以避免语法问题.(element.style.background-image看起来你正在做减法.)Firefox也可能是渐进式的,也可以允许破折号,但IE ......似乎没有.