www.webdeveloper.com
Results 1 to 3 of 3

Thread: trouble pulling from getElementbyId

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    trouble pulling from getElementbyId

    Hey guys. I have a thumbnail gallery that replaces the src of the main image onclick. What I would like to do is display the title attribute (or even better yet if possible, an html snippet unique to each image) when the new image is placed. The thumbnail gallery switcher works fine, but I can't get the title attribute to display. I tried this method:


    Code:
    <div id="large"><img src="images/1.jpg" id="large" title="image 1" name="ID#-04" alt="fda" />
    			
    			</div>
    
    <script type="text/javascript">
    document.write(document.getElementById("large").title);
    </script>
    Any ideas? If its not too difficult I'd prefer the unique html snippet, but if its a hassle this will be fine. Thank you guys!

  2. #2
    Join Date
    Jun 2009
    Posts
    6
    Hi tm04,

    It seems you've placed the same ID name into both your DIV and IMG tags. You should only need it in the IMG tag (ie. remove or change the ID in the DIV tag)...then your script should work.

    -j

  3. #3
    Join Date
    Aug 2007
    Posts
    3,767
    Ids must be unique. So they can only be used once on the page.

    Names, and class names can be used multiple times. Only one name can be given to each element, while multiple classnames can be.
    Great wit and madness are near allied, and fine a line their bounds divide.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles