我怎樣才能得到這個CSS聲明:如何在JQuery中編寫CSS簡寫值?
background: #232222 url("../img/big-team.jpg") no-repeat fixed;
在這裏:
$('.class ').css('background', ' //code should be injected here ');
預先感謝您!
我怎樣才能得到這個CSS聲明:如何在JQuery中編寫CSS簡寫值?
background: #232222 url("../img/big-team.jpg") no-repeat fixed;
在這裏:
$('.class ').css('background', ' //code should be injected here ');
預先感謝您!
只要你在你的CSS使用這樣的:
$('.class ').css('background', '#232222 url("../img/big-team.jpg") no-repeat fixed');
只需複製並粘貼您的CSS聲明:
$('.class').css('background', '#232222 url("../img/big-team.jpg") no-repeat fixed');
您還可以通過CSS縮寫性質嘗試
$(".class").css({
"background-color":"#232222",
"background-image": "url('../img/big-team.jpg')",
"background-repeat":"no-repeat",
"background-position":"fixed"
});
爲什麼你不創建CSS類,並使用'$('。class')。addClass('CSSClassName');' –
不要粗魯但如果你已經嘗試將你的CSS屬性值放入'//代碼應該在這裏注入',你自己就會找到答案。 – Harry