Change html background image with jQuery
10,246
Solution 1
Try this:
$('body').css({background : 'url(images/wallpaper/'+wp+'.jpg) no-repeat fixed bottom left'});
Solution 2
$('body').css({background : 'url(images/wallpaper/'+wp+'.jpg) no-repeat fixed bottom left'});
It's just like the CSS property of the same name.
background
is a shortcut to setting background-image
, background-repeat
, background-attachment
, background-position
etc.
Solution 3
Change backgroundImage
to background
.
Author by
Gustavo Porto
Updated on June 04, 2022Comments
-
Gustavo Porto almost 2 years
I need change the background image, so I using:
$('body').css({backgroundImage : 'url(images/wallpaper/'+wp+'.jpg)'});
But, I need use the properties: no-repeat fixed bottom left
If I try:
$('body').css({backgroundImage : 'url(images/wallpaper/'+wp+'.jpg) no-repeat fixed bottom left'});
Its not work. someone can solve it?