JavaScript implements the method of randomly replacing images
- 2020-05-30 19:20:28
- OfStack
This article illustrates an example of how JavaScript can randomly replace images. Share with you for your reference. The details are as follows:
The following code can be implemented to randomly replace the image on the page with another image, or randomly display 1 image
<script>
document.write(<img src="img/+parseInt(Math.random()*(5))
+.gif"height="40" width="50">
</script>
The image file is called: 0.gif 1.gif 2.gif 3.gif 4.gif
I hope this article has been helpful to your javascript programming.