tags:

views:

19

answers:

2

I know im doing something wrong here:

document.getElementById("body_bg_top").style.background-image:url(main_bg_top.jpg);

if any one can correct me i would appriciete it !

thank you

+1  A: 

background-image has no hyphen, so just

document.getElementById("body_bg_top").style.backgroundImage="url(main_bg_top.jpg)";

Also need to replace the colon with an equals and wrap the url() in quotes.

http://www.w3schools.com/jsref/prop_style_backgroundimage.asp

tsgrasser
fixed, heh. Teach me to copy/paste...
tsgrasser
A: 

With jQuery, you can use:

$('#element-name').css('background-image');

to access that particular CSS property.

a.feng
Why use jQuery for a simple task?
Felix Kling
I'm just providing another method of doing this. I guess it wouldn't be necessary for this specific example to use jQuery, but it might be easier if you're trying to do a lot of these type of selectors/manipulations.
a.feng