开发者

document.write loop not working remotely

The problem: doesnt output an image. image name (1).jpg up to (42).jpg

<script type=text/javascript>
  var i=1;
    while (i<=42) {
      document.write("<div style=min-height:200px; onmouseover=\"innerHTML=\'<img style=width:800px; src=(");
      document.write(i);
      docum开发者_高级运维ent.write(").jpg/>\'\">Hover</div>" + i);
      i++;
  }
</script>

Additional info:

  • tried this locally with wamp and it worked fine


This is the result of the above code:

<div style="min-height:200px;" onmouseover="innerHTML='&lt;img style=width:800px; src=(1).jpg/&gt;'"><img style="width:800px;" src="(1).jpg/"></div>

What do you mean that is not working? If you mean that does not display the images after the hover then you have to correct the image path.

Look if the images are located in the same folder with the page that run that code, otherwhise correct the path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜