본문 바로가기

Web/JQuery

제이쿼리 슬라이드 화면 실습

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js " language="javascript" type="text/javascript" charset="utf-8"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function(){
  $("#next").on("click", function() {
   $(".container > div:visible").each(function(index) {
    if(index == 0) {
     $(".container > div:hidden").first().css("display", "block").addClass("add").clone().insertBefore(this);
     $(this).first().css("display", "none").appendTo(".container");
     $(".container > .add").eq(0).remove();
    }
   });
  });
  
  $("#prev").on("click", function() {
   $(".container > div:visible").each(function(index){
    if(index == 0) {
     $(".container > div:hidden").last().css("display", "block").clone().insertBefore(this);
     $(".container > div").last().remove();
     $(".container > div:visible").last().css("display", "none");
    }
   });
  });  
 });
</script>
</head>
<body>
 <div class="container">
  <div class="hello">Hello</div>
  <div class="goodbye">Goodbye</div>
  <div class="goodrun">GoodLight</div>
  <div class="goodshow1" style="display: none;">goodshow1</div>
  <div class="goodshow2" style="display: none;">goodshow2</div>
  <div class="goodshow3" style="display: none;">goodshow3</div>
  <div class="goodshow4" style="display: none;">goodshow4</div>
  <div class="goodshow5" style="display: none;">goodshow5</div>
 </div>
<br/><br/><br/><br/>
<input type="button" value="prev" id="prev"/>
<input type="button" value="next" id="next"/>
</body>
</html>