콜백 : 매개변수로 함수를 전달


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>콜백 : 매개변수로 함수를 전달</title>
<script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script>
<style type="text/css"></style>
<script type="text/javascript">

 $(document).ready(function() {
    $('p:eq(1)')                                         // 두번째 p 태그 영역
       .css('backgroundColor','Yellow')       // 두번째 영역의 배경색 지정
       .click(function() {                              // 두번째 영역을 클릭했을때
            var $thisPara = $(this);                  // 현재 영역을 변수에 설정
            $thisPara.next().slideDown('slow', function() { // 두번째의 다음 요소를 슬라이드 다운
                $thisPara.slideUp('slow');
            });
       });
  });
 
</script>
<body>
  <p>첫번째</p>
  <p>두번째</p>
  <p style="display:none;">세번째</p>
  <p>네번째</p>
</body>
</html>