웹프로그래밍

Global It Leader!!


jQuery


 
 

레이어 보이기 숨기기 및 버튼 토글(열기, 닫기)

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,690회 작성일 12-03-08 23:28

본문

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link type="text/css" rel="stylesheet" href="kaplan.css" media="screen" />
 
<style type="text/css">
.exp_box {
 background-color: #FFFFFF;
 padding: 10px;
 margin: 4px 10px 16px 0;
 border: 1px solid #c4c4c4;
 text-align: justify;
 line-height: 18px;
 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
 border-radius: 10px;
 -moz-box-shadow: inset 0 0 30px #DDDDDD;
 -webkit-box-shadow: inset 0 0 30px #DDDDDD;
 box-shadow: inset 0 0 30px #DDDDDD;
 overflow: hidden;
 display: none;
 font-family: Tahoma, Geneva, sans-serif;
}
.exp_box p {
 margin: 0;
 padding: 0;
}
.close_box {
 text-align: right;
 display: block;
 padding: 0 0 0 0;
}
.exp_box h3 {
 margin: 0 0 -16px 0;
 padding: 0; 
 color: #415bf5;
 font-size: 17px;
}
#box_button {
 vertical-align: -3px;
 margin: 0 0 0 6px;
}
.show_hide {
 cursor: pointer;
}
</style>
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
(function ($) {
 $(document).ready(function(){
     $('.show_hide').showHide({   
   speed: 400,  // speed you want the toggle to happen 
   easing: '',  // the animation effect you want. Remove this line if you dont want an effect and if you haven't included jQuery UI
   changeText: 0, // if you dont want the button text to change, set this to 0
   showText: 'View',// the button text to show when a div is closed
   hideText: 'Close' // the button text to show when a div is open
     
  });
 
 });

    $.fn.showHide = function (options) {
 
  //default vars for the plugin
        var defaults = {
            speed: 1000,
   easing: '',
   changeText: 0,
   showText: 'Show',
   hideText: 'Hide'
   
        };
        var options = $.extend(defaults, options);
  var flag=0;
       
  $(this).click(function () { 
          
             $('.toggleDiv').slideUp(options.speed, options.easing); 
    // this var stores which button you've clicked
             var toggleClick = $(this);
       // this reads the rel attribute of the button to determine which div id to toggle
       var toggleDiv = $(this).attr('rel');
       // here we toggle show/hide the correct div at the right speed and using which easing effect
       $(toggleDiv).slideToggle(options.speed, options.easing, function() {
       // this only fires once the animation is completed
    if(options.changeText==1){
       $(toggleDiv).is(":visible") ? toggleClick.text(options.hideText) : toggleClick.text(options.showText);
    }
              });

   var img = $(this).find('img');
   var src = img.attr('src');
   
   //image is open
   if(src == 'box_open.gif') {        
    img.attr('src','box_close.gif');        
   }     
   //image is close
   if(src == 'box_close.gif') {        
    img.attr('src','box_open.gif');        
   }

    return false;
        
        });
 
    };
})(jQuery);
</script>
</head>
<body>
<div style="width: 600px; font-size: 12px">
 <h2><strong>Title</strong></h2>
 <ul>
  <li>
   
   <a class="show_hide" rel="#slidingDiv1">Intensive English Courses<img name="img1" src="box_open.gif" alt="Box Open" id="box_button" /></a>
   <div id="slidingDiv1" class="exp_box">
    <p>
     <h3>Intensive English Courses</h3><br />
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus imperdiet nibh a risus blandit ut fringilla ante adipiscing. Donec non ligula elit. Nulla suscipit dapibus vulputate. Cras purus dolor, scelerisque sed congue sed, aliquet pellentesque nisi. Suspendisse sed odio at mi iaculis elementum vitae a tellus. Nulla ac adipiscing enim. Pellentesque vulputate purus et nisl rhoncus volutpat. Proin dapibus, tortor nec dignissim lobortis, tortor nulla facilisis sapien, vitae rhoncus lorem lorem nec leo. Ut a tellus euismod neque feugiat ultricies fringilla id nisi. Integer eget justo ipsum. Pellentesque metus ipsum, egestas at molestie consequat, semper eget mi. Integer non ante in sem iaculis pretium. Suspendisse nec massa eget leo fringilla iaculis in a nulla. Duis at lobortis odio. Quisque in nunc velit. Sed pulvinar sem non felis dapibus dictum.
    </p>
   </div>
  </li>
  <li>Intensive English Academic Year and Semester</a></li>
  <li>
   <a class="show_hide" rel="#slidingDiv2">OPUS Paid work and study<img src="box_open.gif" alt="Box Open" id="box_button" /></a>
   <div id="slidingDiv2" class="exp_box">
    <p>
     <h3>OPUS Paid work and study</h3><br />
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus imperdiet nibh a risus blandit ut fringilla ante adipiscing. Donec non ligula elit. Nulla suscipit dapibus vulputate. Cras purus dolor, scelerisque sed congue sed, aliquet pellentesque nisi. Suspendisse sed odio at mi iaculis elementum vitae a tellus. Nulla ac adipiscing enim. Pellentesque vulputate purus et nisl rhoncus volutpat. Proin dapibus, tortor nec dignissim lobortis, tortor nulla facilisis sapien, vitae rhoncus lorem lorem nec leo. Ut a tellus euismod neque feugiat ultricies fringilla id nisi. Integer eget justo ipsum. Pellentesque metus ipsum, egestas at molestie consequat, semper eget mi. Integer non ante in sem iaculis pretium. Suspendisse nec massa eget leo fringilla iaculis in a nulla. Duis at lobortis odio. Quisque in nunc velit. Sed pulvinar sem non felis dapibus dictum.
    </p>
   </div>
  </li>
  <li>
   <a class="show_hide" rel="#slidingDiv3">Internship placement service<img src="box_open.gif" alt="Box Open" id="box_button" /></a>
   <div id="slidingDiv3" class="exp_box">
    <p>
     <h3>Internship placement service</h3><br />
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus imperdiet nibh a risus blandit ut fringilla ante adipiscing. Donec non ligula elit. Nulla suscipit dapibus vulputate. Cras purus dolor, scelerisque sed congue sed, aliquet pellentesque nisi. Suspendisse sed odio at mi iaculis elementum vitae a tellus. Nulla ac adipiscing enim. Pellentesque vulputate purus et nisl rhoncus volutpat. Proin dapibus, tortor nec dignissim lobortis, tortor nulla facilisis sapien, vitae rhoncus lorem lorem nec leo. Ut a tellus euismod neque feugiat ultricies fringilla id nisi. Integer eget justo ipsum. Pellentesque metus ipsum, egestas at molestie consequat, semper eget mi. Integer non ante in sem iaculis pretium. Suspendisse nec massa eget leo fringilla iaculis in a nulla. Duis at lobortis odio. Quisque in nunc velit. Sed pulvinar sem non felis dapibus dictum.
    </p>
   </div>
  </li>
 </ul>
</div>
</body>
</body>
</html>

댓글목록

등록된 댓글이 없습니다.

전체 142
게시물 검색
jQuery 목록
번호 제목 글쓴이 조회 날짜
62 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4055 11-29
61 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6624 09-17
60 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5504 08-21
59 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4855 08-21
58 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6416 07-13
57 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5976 06-13
56 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5305 04-28
55 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5484 04-24
54 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4865 04-24
53 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5764 04-24
52 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4824 04-24
51 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4391 04-20
50 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4019 04-19
49 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4382 04-19
48 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4030 04-17
47 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4343 04-11
46 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4408 04-01
45 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4574 04-01
44 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4274 03-31
43 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4343 03-22