tinku92
tinku92

Reputation: 109

Changing the background image of <html> with jQuery not working

I know it's possible to change the background image for body or div tags, but is it possible to add or change the background image for the html tag?

I tried the following, but it didn't work:

$("html").css('background', 'url(../images/myImage.jpg)');

Is there another way?

Upvotes: 0

Views: 104

Answers (2)

WearFox
WearFox

Reputation: 293

This method is perfec

var id_of_div ="contenedor";
document.getElementById(id_of_div).style.backgroundImage='http://conectica.com.mx/wp-content/uploads/2013/08/youtube-ios.png';

that's all

Upvotes: 0

user3567510
user3567510

Reputation:

Try $('body').parent().css('background', 'url(imagePath)'). It should work.

Upvotes: 1

Related Questions