JQuery 는 이미지를 임의로 선택합니다.

js 코드

var rand1 = 0;
var useRand = 0;
images = new Array;
images[1] = new Image();
images[1].src = "http://goods.hnysnet.com/zb_users/theme/goods/style/images/w1.jpg";
images[2] = new Image();
images[2].src = "http://goods.hnysnet.com/zb_users/theme/goods/style/images/w2.jpg";
images[3] = new Image();
images[3].src = "http://goods.hnysnet.com/zb_users/theme/goods/style/images/w3.jpg";
images[4] = new Image();
images[4].src = "http://goods.hnysnet.com/zb_users/theme/goods/style/images/w4.jpg";
 
images[5] = new Image();
images[5].src = "http://goods.hnysnet.com/zb_users/theme/goods/style/images/w5.jpg";
function swapPic() {
var imgnum = 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;
}


html 코드

<div class="wx_content">
        <img name="randimg" src="http://goods.hnysnet.com/zb_users/theme/goods/style/images/w1.jpg">
</div>


응용 프로그램 인스턴스:

image.png

태그:Jquery
싫다1

이 문서의 링크:https://ko.finchui.com/program/39.html

네티즌 댓글

아마 좋아하실 겁니다.

인기 상품
인기 기사
핫 레이블
관련 레이블
Finch UI 스토어 버전

공유

링크 복사
출 근 시간 : 9: 00 ~ 22: 00
토요일, 일요일: 14: 00 - 22: 00
wechat
코드를 스캔하여 고객서비스 위챗을 추가하다