无法使用javascript更改图片src

时间:2019-02-20 00:45:51

标签: javascript

当我单击2 img not identique时,我希望将其更改为另一张img,但无法正常工作

function changeImage1()
{
  var img1 =document.getElementById("image_change");
  var img2 =document.getElementById("image_change1");
  var img3 =document.getElementById("image_change2");

  if(img1.src===img2.src)
  {
    setTimeout( function ( ) { alert( "identique" ); }, 1000 );
  }
  else if(img1.src === img3.src)
  {
    document.getElementById("image_change").src="img111.jpg";
    document.getElementById("image_change2").src="img111.jpg";

    setTimeout(changeImage1, 1000);
  }
} 

0 个答案:

没有答案