css样式到jquery - 多个属性

时间:2015-02-10 23:24:01

标签: javascript jquery html css

我已经在我的css文件中输入了这个:

    background:url("img/gold1.gif") repeat-x center;

现在我想将其更改为jQuery语言,但我不知道如何:( 我有这个:

$('#example').css( {"background": "url('img/gold1.gif')", "background-repeat": "repeat-x", "background-position": "center"; });

它不起作用。有什么帮助吗?

2 个答案:

答案 0 :(得分:1)

"background-position": "center";语法无效。删除半结肠

答案 1 :(得分:0)

这应该可行,在中心后删除分号:

$('#example').css({
    "background": "url('img/gold1.gif')",
    "background-repeat": "repeat-x",
    "background-position": "center"
});
相关问题