why is this happening to all images?

Discussion in 'HTML & Website Design' started by whocky, Feb 5, 2008.

  1. #1
    Hi all

    i have a website im currently working on ( www dot alfalimos dot com )
    on the left we have 4 images that when you have the mouse over we wanted a bigger picture, we have this working using this code:

    <style type="text/css">
    <!--
    .enlarge{width:auto;height:auto;}
    -->
    </style>
    <script type="text/JavaScript">
    <!--

    //set ALL images for the rollover effect
    window.onload=function(){
    var imgArr = document.getElementsByTagName('img');
    for(var i=0;i<imgArr.length;i++){
    imgArr.onmouseover = function(){this.className='enlarge';}
    imgArr.onmouseout = function(){this.className='';}
    }
    }
    //-->
    </script>

    Though this is causing all images on that page to go large, how do we stop it from doing it to all and just the 4 we intended it to work on.

    thanks in advance
    whocky
     
    whocky, Feb 5, 2008 IP
  2. nfd2005

    nfd2005 Well-Known Member

    Messages:
    295
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Try adding a parent element to your imgArr:

    var imgArr = document.getElementsById('photos').document.getElementsByTagName('img');
     
    nfd2005, Feb 5, 2008 IP