슬라이드 쇼용 JS (jQuery) 스크립트를 작성했습니다. 매우 간단하고 다음/이전 버튼 만 있습니다. 지금 :jQuery 슬라이드 쇼 코드가 완벽하게 작동하지 않습니다.
문제는 슬라이드 쇼가 매끄럽지 않다는 것입니다. 다음/이전 버튼을 누르면 빈 이미지도 표시됩니다. 그래서,이 세 가지 이미지를 얻고 경우 이미지 # 1에서 이동을 시작,이 같은 상황이 발생합니다
1 # -> # 2 -> 3 번 -> 빈
동안 대신 빈 # 1 이미지로 돌아 가야하지만 그렇지 않습니다.
: 여기$(document).ready(function() {
var x = $('.slide_top').children('p');
x.hide();
var i = 0;
x.eq(i).show();
$("#slide_next").click(function(event){
event.stopPropagation();
event.preventDefault();
x.eq(i).hide();
x.eq(i).next().show();
i = i + 1;
if(i === x.length)
{
i = 0;
}
});
$("#slide_prev").click(function(event){
event.preventDefault();
event.stopPropagation();
x.eq(i).hide();
x.eq(i).prev().show();
i = i - 1;
if(i == x.length)
{
i = 0;
}
});
});
는 HTML 코드입니다 :
여기 http://jsfiddle.net/mostafatalebi/SG3Rq/
는 JS 코드입니다 (대신 IMG의 내가 넣어 가지고 P) 여기
는 jsFiddle 코드입니다
<div class='slide_top'>
<p>This is the first Paragraph</p>
<p>This is the second Paragraph</p>
<p>This is the third Paragraph</p>
</div>
<ul id='slide_top_click'>
<li><a id='slide_prev' href='#' class='slide-next-icon'>Next</a></li>
<li><a id='slide_next' href='#' class='slide-prev-icon'>Previous</a></li>
</ul>