SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change IMG title or alt with Javascript

    I have a function that rolls out a new image if success:

    function changeimage(img_name) {
    document[img_name].src='/images/user/dot-success.gif';
    }

    Is there anyway I can change the title (title="") or/and alt (alt="") of that same image?

    Thanks
    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code:
    document[img_name].alt='alt text';
     document[img_name].title='title text';
    or
    Code:
    document[img_name].setAttribute('alt', 'alt text');
    document[img_name].setAttribute('title', 'title text');


Bookmarks

Posting Permissions

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