Reply
backgroundImage Change
Old 04-23-2008, 02:15 PM backgroundImage Change
Extreme Talker

Posts: 162
I have a JS function that I want to change the background of a <div> with the id="HLimg". It uses an external stylesheet if that makes a difference.

Code:
document.HLimg.style.backgroundImage="url(../images/thumbs/waltdisney.jpg)";
When I run the code I get the error
Quote:
'document.HLimg.style' is null or not an object
Any ideas?
__________________
DVD Movie Release Database: http://www.couchpotatoesonline.com
Truly is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-23-2008, 06:04 PM Re: backgroundImage Change
wayfarer07's Avatar
Insomniac

Posts: 542
Name: Abel Mohler
Location: Asheville, North Carolina USA
try this:
Code:
document.getElementById('HLimg').style.backgroundImage="url(images/thumbs/waltdisney.jpg)";
Note that I didn't put a '../' before your images folder because it probably isn't needed. That reference only used when targeting a down-level directory, like from an external CSS file that is in its own folder...
__________________
Go FREELANCE <=====||=====> Hire Me
wayfarer07 is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 01:51 PM Re: backgroundImage Change
Extreme Talker

Posts: 162
Brilliant! Worked like a charm. Thanks!
__________________
DVD Movie Release Database: http://www.couchpotatoesonline.com
Truly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to backgroundImage Change
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11705 seconds with 13 queries