Javascript 使用变量时背景未设置动画

Javascript 使用变量时背景未设置动画,javascript,jquery,css,background,transition,Javascript,Jquery,Css,Background,Transition,我正在使用css转换,这些转换是使用jquery为幻灯片添加的,尽管出于某些原因,它没有设置元素背景的动画 以下是我正在使用的代码: $(this).find('.pagers').children().css('-webkit-transition-property', 'background'); $(this).find('.pagers').children().css('-webkit-transition-timing-function', 'linear'); $(this).fi

我正在使用css转换,这些转换是使用jquery为幻灯片添加的,尽管出于某些原因,它没有设置元素背景的动画

以下是我正在使用的代码:

$(this).find('.pagers').children().css('-webkit-transition-property', 'background');
$(this).find('.pagers').children().css('-webkit-transition-timing-function', 'linear');
$(this).find('.pagers').children().css('-webkit-transition-duration', du);
$(this).find('.pagers').children().css('-moz-transition-property', 'background');
$(this).find('.pagers').children().css('-moz-transition-timing-function', 'linear');
$(this).find('.pagers').children().css('-moz-transition-duration', du);
$(this).find('.pagers').children().css('-o-transition-property', 'background');
$(this).find('.pagers').children().css('-o-transition-timing-function', 'linear');
$(this).find('.pagers').children().css('-o-transition-duration', du);
$(this).find('.pagers').children().css('-ms-transition-property', 'background');
$(this).find('.pagers').children().css('-ms-transition-timing-function', 'linear');
$(this).find('.pagers').children().css('-ms-transition-duration', du);
$(this).find('.pagers').children().css('transition-property', 'background');
$(this).find('.pagers').children().css('transition-timing-function', 'linear');
$(this).find('.pagers').children().css('transition-duration', du);
我不能只使用常规css转换,因为我使用的是变量

我已经试过了。虽然不起作用,但还是用动画代替

提前感谢

这样做:

$('.pager').css({
      '-webkit-transition' : 'background-color '+du+'s linear'      
});

当然,您必须为所有浏览器添加代码

什么是“我不能只使用常规浏览器,因为我使用的是变量。”意思是什么?一个普通的什么和什么类型的变量?我不能使用css,因为这是一个为幻灯片设置持续时间的插件。这个变量是由pluginAh的用户设置的,一个持续时间的变量。css()方法接受一个对象,所以你不必多次写入所有内容。否则,变量的使用方式似乎没有任何问题,因此要么选择器错误,要么变量不是您认为的那样,要么您没有设置适当的css属性。我们没办法知道,除非你摆好小提琴或者我们可以测试的东西?