- 이미지를 클릭할 때마다 해당 폴더 내의 다음 이미지로 넘어가는 예제입니다.
- 애니메이션을 부여하여 부드럽게 전환되도록 할 수 있습니다.
- 이미지가 만료되면 처음으로 돌아갑니다.
- 이미지는 image 폴더 안에 들어있습니다.
↓ ↓ ↓ ↓ ↓ <시작 | 파일명 파일명 : jq8.html > ↓ ↓ ↓ ↓ ↓
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.imag{position :absolute;
top: 10px;
left: 10px;
} /* absolute:절대위치, relative: 상대위치, fixed : 고정위치 */
</style>
<script type="text/javascript">
$(document).ready(function(){
$(".imag").hide();
$(".imag:first").fadeIn('slow');
var next;
$(".imag").click(function(event){
$(this).fadeIn('slow');
//alert($(this).next().length);
next = ($(this).next().length)?$(this).next():$(".imag:first");
$(this).fadeOut('slow'); // 현재 이미지 숨기기
next.fadeIn('slow'); // 다음 이미지 출현
event.preventDefault(); // 웹의 초기화 해제
});
});
</script>
</head>
<body>
<a class="imag" href="">
<img src="image/1.jpg" width="300" height="300">
</a>
<a class="imag" href="">
<img src="image/2.jpg" width="300" height="300">
</a>
<a class="imag" href="">
<img src="image/3.jpg" width="300" height="300">
</a>
<a class="imag" href="">
<img src="image/4.jpg" width="300" height="300">
</a>
<a class="imag" href="">
<img src="image/1.jpg" width="300" height="300">
</a>
</body>
</html>
↑ ↑ ↑ ↑ ↑ <종료 | 파일명 파일명 : jq8.html > ↑ ↑ ↑ ↑ ↑
댓글 영역