Results 1 to 5 of 5

Thread: change image on list over

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default change image on list over

    Hi

    I've got a list with few links and images:

    PHP Code:
    <ul id="idList">
    <
    li class="iactive"><a href="#"><img src="2.gif" alt="" border="0" />pap1</a></li>
    <
    li><a href="#"><img src="1.gif" alt="" border="0" />good</a></li>
    <
    li><a href="#"><img src="1.gif" alt="" border="0" />good</a></li>
    <
    li><a href="#"><img src="1.gif" alt="" border="0" />good</a></li>
    <
    li><a href="#"><img src="1.gif" alt="" border="0" />good</a></li>
    <
    li><a href="#"><img src="1.gif" alt="" border="0" />good</a></li>
    </
    ul
    Except for the first list, I want that the whole other lists will change the image 1.gif onmouseover to 3.gif

    it is important that it won't be regular image change onMouseOver, because I want that also when the mouse will be on the word "good" the image will be changed.


    Thank you very much!

  2. #2
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Code:
    <ul id="idList">
    <li class="iactive"><a href="#"><img src="2.gif" alt="" border="0" />pap1</a></li>
    <li><a href="#"><img src="1.gif" alt="" border="0" />good</a></li>
    <li><a href="#" onmouseover="getElementById('myimg1').src='3.gif'"><img id="myimg1" src="1.gif" alt="" border="0"/>good</a></li>
    <li><a href="#" onmouseover="getElementById('myimg2').src='3.gif'"><img src="1.gif"  id="myimg2" alt="" border="0"/>good</a></li>
    <li><a href="#" onmouseover="getElementById('myimg3').src='3.gif'"><img src="1.gif"  id="myimg3" alt="" border="0"/>good</a></li>
    <li><a href="#" onmouseover="getElementById('myimg4').src='3.gif'"><img src="1.gif"  id="myimg4" alt="" border="0"/>good</a></li>
    </ul>
    I'm not js expert but try this out

  3. The Following User Says Thank You to allahverdi For This Useful Post:

    d-machine (07-07-2008)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Except for the first list? You have only shown us one list. I think you meant 'list item'.

    Even so, it still isn't clear what must change, but I am assuming something like so will do:

    Code:
    <ul id="idList"> 
    <li class="iactive"><a href="#"><img src="2.gif" alt="" border="0" />pap1</a></li> 
    <li><a href="#" onmouseover="document.images['limg1'].src = '3.gif';"><img name="limg1" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg2'].src = '3.gif';"><img name="limg2" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg3'].src = '3.gif';"><img name="limg3" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg4'].src = '3.gif';"><img name="limg4" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg5'].src = '3.gif';"><img name="limg5" src="1.gif" alt="" border="0" />good</a></li> 
    </ul>
    I'm also assuming that you want them to change back onmouseout. If so, add the corresponding onmouseout event to each link, example:

    Code:
    onmouseout="document.images['limg1'].src = '1.gif';"
    Just be sure to use the matching ['limg#'] for each one.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    d-machine (07-07-2008)

  6. #4
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Except for the first list? You have only shown us one list. I think you meant 'list item'.

    Even so, it still isn't clear what must change, but I am assuming something like so will do:

    Code:
    <ul id="idList"> 
    <li class="iactive"><a href="#"><img src="2.gif" alt="" border="0" />pap1</a></li> 
    <li><a href="#" onmouseover="document.images['limg1'].src = '3.gif';"><img name="limg1" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg2'].src = '3.gif';"><img name="limg2" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg3'].src = '3.gif';"><img name="limg3" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmou
    
    seover="document.images['limg4'].src = '3.gif';"><img name="limg4" src="1.gif" alt="" border="0" />good</a></li> 
    <li><a href="#" onmouseover="document.images['limg5'].src = '3.gif';"><img name="limg5" src="1.gif" alt="" border="0" />good</a></li> 
    </ul>
    I'm also assuming that you want them to change back onmouseout. If so, add the corresponding onmouseout event to each link, example:

    Code:
    onmouseout="document.images['limg1'].src = '1.gif';"
    Just be sure to use the matching ['limg#'] for each one.
    Your'e my hero!

    thank you both

  7. #5
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    No problems. Happy when i can help you

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
  •