1
div에 5 개의 이미지가 있습니다. [1] [2] [3] [4] [5] 자바 스크립트를 자동으로 [2] [3] [4] [5] [1] 그리고 [3] [4] [5] [1] [2] 등으로 바꾸고 싶습니다. 지금은 첫 번째 이미지 만 변경했습니다. 내가 가지고있는 스크립트를 사용하여 모든 것을 변경할 수 있습니까? 미리 감사드립니다. (내가 자바 스크립트에서 초보자 해요, jQuery를 모른다.)사진 갤러리 -javascript
var i = 1;
var x = ["img/facebook.png", "img/linkedin.png", "img/mail.png", "img/twiter.png", "img/skype.png"];
var y = ["1", "2", "3", "4", "5"];
function slide(num) {
i = i + num;
\t if(i < 0) i = x.length - 1;
\t if (i > x.length - 1) i = 0 \t
document.getElementById('image01').src = x[i];
\t document.getElementById('text01').innerHTML = i;
}
function autorun(){setInterval("slide(1)", 3000);}
body{margin: 0; padding: 0; color:#fdbf7d; font-family: courier new;}
.container{margin-left:auto; margin-right:auto; width:940px; padding:10px; background-color: yellow;}
#photo_gallery_container{background-color: brown;}
#photo_gallery{}
<!doctype html>
<html lang="en">
<head>
<title>Gallery</title>
<meta http-equiv="content" content="text/html"; charset=UTF-8>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body onload="autorun()">
<div class="container">
<div id="photo_gallery_container">
\t <div id="photo_gallery">
\t \t <center>
\t \t <img id="image01" src="img/facebook.png" width="100px" height="100px">
\t \t <img id="image02" src="img/linkedin.png" width="100px" height="100px">
\t \t <img id="image03" src="img/mail.png" width="100px" height="100px">
\t \t <img id="image04" src="img/twiter.png" width="100px" height="100px">
\t \t <img id="image05" src="img/skype.png" width="100px" height="100px">
\t \t \t <span id="text01">1</span>
\t \t \t <span id="text02">2</span>
\t \t \t <span id="text03">3</span>
\t \t \t <span id="text04">4</span>
\t \t \t <span id="text05">5</span>
\t \t </center> \t
\t \t </div>
\t \t <script type="text/javascript" src="myscript.js"></script>
\t </div>
</div>
</body>
</html>
당신은 addChild 및 addChild를 사용하거나 jQuery를 태그로 사용할 수 있습니다. – mplungjan