0

与 jQuery('.class').css(...); 相比,我有一个奇怪的问题。

jQuery('#ns-background-repeat').on('change', function(){
    //alert(jQuery(this).val());
    jQuery(this).css({ 'background-repeat' : jQuery(this).val() });
    jQuery('.test').text(  jQuery(this).css('background-repeat') );
});

请让我知道为什么它不起作用:http: //jsfiddle.net/eXa4y/2/

铬: http: //gyazo.com/42cd909cc0b1c17023975f034e5a4728

火狐: http: //gyazo.com/aa74f7e00fd898a7c43c2d7e44d0d17c - 效果很好。

4

1 回答 1

1

这个jsfiddle可能有助于描述情况

每个浏览器的结果都与背景重复的 CSS3 规范一致

设置时$someElement.css({ 'background-repeat' : 'repeat-x' });

Chrome 将 style 属性设置为background-repeat: repeat no-repeat;

Firefox/IE 将样式属性设置为background-repeat: repeat-x;

(在每个浏览器 Chrome 30、FF 24、IE 10 的最新版本中进行测试)

规范指定

'repeat-x' 计算为'repeat no-repeat'。

所以两者在技术上是等价的,只是实现方式不同。

重复-x = x:重复,y:不重复

于 2013-10-02T19:03:08.940 回答