Imoddedu Posted July 27, 2011 Share Posted July 27, 2011 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)'); }); Link to comment Share on other sites More sharing options...
thescientist Posted July 27, 2011 Share Posted July 27, 2011 did you try background-image? Link to comment Share on other sites More sharing options...
Imoddedu Posted July 27, 2011 Author Share Posted July 27, 2011 How is that different from just background? I currently use background right now in the CSS and it shows up Link to comment Share on other sites More sharing options...
justsomeguy Posted July 28, 2011 Share Posted July 28, 2011 Does that mean you're not going to try it? Link to comment Share on other sites More sharing options...
Imoddedu Posted July 28, 2011 Author Share Posted July 28, 2011 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? Link to comment Share on other sites More sharing options...
Obi1-Cannabis Posted July 28, 2011 Share Posted July 28, 2011 the code you've posted originaly should be working fine, are you sure that the id #webDesignLink and the path to your image are correct.try using the absolute path to your image intead of relative path just to be sure. Link to comment Share on other sites More sharing options...
thescientist Posted July 28, 2011 Share Posted July 28, 2011 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.