この記事では、JS Mouseの画像をクリックして、ランダムに変更する方法について説明します。参照のためにそれを共有してください。特定の実装方法は次のとおりです。
<html> <title>マウスで画像をクリックして画像をランダムに変換します</title> <body bgcolor = "#fef4d9" onload = "swappic()" swappic() ""> <center> <center> <script言語= "javascript"> <! "/m01.jpg"; images [2] = new image(); yages [2] .src = "images/m02.jpg"; images [3] = new image(); emages [3] .src = "images/m03.jpg"; images [4] = new images(); mage/m04.jpg "; Images.length -1; do {var randnum = math.random(); rand1 = math.round((imgnum -1) * randnum) + 1;} while(rand1 == userand); userand = rand1; document.randimg.src = images [userand] .src;} name = "randimg" src = "images/m09.jpg"> </a> <br> <font face = "verdana" size = "-2">画像をクリックして変更</center> </body> </html>この記事がみんなのJavaScriptプログラミングに役立つことを願っています。