이 기사에서는 JS 마우스의 이미지를 클릭하여 무작위로 사진을 변경하는 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
<html> <title> 마우스가있는 이미지를 클릭하여 이미지를 무작위로 변환하려면 </title> <body bgcolor = "#fef4d9"onload = "swappic ()"> <center> <script ancerain = "javaScript"> <!- beginvar rand1 = 0; var userand = 0; 이미지 [1] = 새로운 이미지 (); "이미지/m01.jpg"; images [2] = new image (); 이미지 [2] .src = "images/m02.jpg"; images [3] = new image (); 이미지 [3] .src = "images/m03.jpg"; images [4] = new image (); 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;} // end-> <a); 이름 = "randimg"src = "images/m09.jpg"> </a> <br> <font face = "Verdana"size = "-2"> 이미지를 클릭하여 변경하려면 </center> </body> </html>이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.