How to reference background image via DOM
I know I'm doing something wrong here:
document.getElementById("body_bg_top").style.background-image:url(main_bg_开发者_如何学编程top.jpg);
If anyone can correct me I would appreciate it, thank you!
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
With jQuery, you can use:
$('#element-name').css('background-image');
to access that particular CSS property.
精彩评论