Jump to content

Changing background image


Imoddedu
 Share

Recommended Posts

Does anybody know how I can change the background image of the body with jQuery? I've tried something like this but it doesn't seem to work:

$("#webDesignLink").hover(function() {				$('body').css('background', 'url(img/bgWeb.png)');			});

Edited by Imoddedu
Link to comment
Share on other sites

Does that mean you're not going to try it?
Of course I am going to try it, I was just curious though.EDIT: It did not change, maybe it isn't supported? Edited by Imoddedu
Link to comment
Share on other sites

I guess you could do it either way, I personally would opt to target the property specifically.as mentioned before, is #webDesignLink a valid element? can you indeed confirm that the hover event is firing?

$("#webDesignLink").hover(function() {  console.log('webDesignLink hover');  $('body').css('background', 'url(img/bgWeb.png)');});

is your javascript in an external file? is the image path relative to the external file?

Edited by thescientist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...