Reputation: 51463
How can I set a CSS property on the html element with jQuery?
I'm trying to do something like...
$('html').css({'background': 'url(/images/bg.png) top center'})
EDIT: For those that will ask why not just set it on the body or some other work around, this needs to be set like this as it fixes a webkit bug in iOS 4
EDIT 2: I guess this is doing what it should already. It must be something with the finicky bug that is causing this to act differently then when I set it via external CSS, strange
Upvotes: 2
Views: 158
Reputation: 25228
There's nothing syntactically incorrect about your jQuery code.
EDIT: Try setting it to the body and the html:
$('html, body').css({'background': 'url(/images/bg.png) top center'})
If you're only doing one change, it's best to use the singular form:
$('html, body').css('background', 'url(/images/bg.png) top center')
Upvotes: 0
Reputation: 2448
Simply like that:
$('html').css('background', 'url(/images/bg.png) top center')
Upvotes: 1
Reputation: 755557
Try the following
$('theSelector').css('background', 'url(/images/bg.png) top center');
For the theSelector
portion you can use the most appropriate jQuery selector for your situation
Upvotes: 0