猿问

求大神帮忙看看


<script>

window.onload = rolloverInit;


function rolloverInit(){

  for(var i=0; i<document.links.length; i++){

    var linkObj = document.links[i];

  

    if(linkObj.className){

      var imgObj = document.getElementById(linkObj.className);

      

      if(imgObj){

        setupRollover(linkObj, imgObj);

      }

    }

  }

}


function setupRollover(thisLink, textImage){

  thisLink.imgToChange = textImage;

    

  thisLink.onmouseout = function(){

    this.imgToChange.src = this.outImage.src;

  }

  thisLink.onmouseover = function(){

    this.imgToChange.src = this.overImage.src;

  }

    

  thisLink.outImage = new Image();

  thisLink.outImage.src = textImage.src;

    

  thisLink.overImage = new Image();

  thisLink.overImage.src = "images/" + thisLink.id + ".png";

}

</script>

</head>


<body>

<div class="left">

<img src="images/海.png">

<a href="#" class="ss" id="haiou"><img src="images/海鸥.jpg" height="100" width="100"></a>

<a href="#" class="ss" id="richu"><img src="images/海上日光.jpg" height="100" width="100"></a>

<a href="#" class="ss" id="haichuang"><img src="images/海之船.jpg" height="100" width="100"></a>

</div>

<div class="right">

<img src="images/背景.png">

</div>


慕粉4240002
浏览 1896回答 3
3回答

永恒君

byId 当然不能用 className 呀。 可以把 class 换成 id,或者用 querySelect 方法

qq_博行天下_04396621

报的什么错
随时随地看视频慕课网APP
我要回答