$(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')");
Share:
18,067
Toni Michel Caubet
Author by

Toni Michel Caubet

Front end developer and wordpress lover; based in Mallorca, Spain. Founder @ Funcook

Updated on June 05, 2022

Comments

  • Toni Michel Caubet
    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
    Toni Michel Caubet about 13 years
    very very very related stackoverflow.com/questions/5253838/… :)
  • Toni Michel Caubet
    Toni Michel Caubet about 13 years
    yup, it's same solution,, but thanks! oh no, ',' VS ':' ..i allways used ':'.. hm..
  • Igor Mironenko
    Igor Mironenko over 11 years
    For 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