Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
backgroundImage Change
Old 04-23-2008, 03:15 PM backgroundImage Change
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
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:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-23-2008, 07:04 PM Re: backgroundImage Change
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
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...
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-24-2008, 02:51 PM Re: backgroundImage Change
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
Brilliant! Worked like a charm. Thanks!
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to backgroundImage Change
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.12389 seconds with 12 queries