$(body).css({'background-image':'url'}) not working
18,067
Solution 1
$(document.body).css(...)
or
$('body').css(...)
Solution 2
how about
$("body").css("background-image","url('/my/image.jpg')");
Author by
Toni Michel Caubet
Front end developer and wordpress lover; based in Mallorca, Spain. Founder @ Funcook
Updated on June 05, 2022Comments
-
Toni Michel Caubet almost 2 years
Shall I assume that I can't apply
.css()
to the body tag?Because if I do it on
$("#div")
... it works? -
Toni Michel Caubet about 13 yearsvery very very related stackoverflow.com/questions/5253838/… :)
-
Toni Michel Caubet about 13 yearsyup, it's same solution,, but thanks! oh no, ',' VS ':' ..i allways used ':'.. hm..
-
Igor Mironenko over 11 yearsFor the confused: $(document.body).css('background-color', 'DDDCCC') - gives me -> .css is not a function in both Firebug and Dragonfly (Opera's console) on some sites. Because document.body must be returning a js object not a jquery one - I'm guessing it's because of frames but I stopped before getting to the bottom of it