May
9
2009

jQuery Effects slideDown

วันนี้เราจะมาแนะนำ Effect slideDown ครับ

รูปแบบของคำสั่งนี้

slideDown( speed, [callback] )

Arguments

  • speed รับค่าเป็น String และ number โดยมีค่าดังนี้ครับ (“slow”, “def”, or “fast”) หรือตัวเลข มีหน่วยเป็นมิลิวินาที เช่น 1000
  • callback นั้นเป็น option คือจะใส่หรือไม่ก็ได้ option นี้เราสามารถใส่ function ที่ต้องการให้ทำงานหลังจากจบการทำงานของ slideDown เสร็จแล้ว

ตัวอย่าง code:

HTML

<div style="background-color:#333333;" ><a id="top" href="javascript:void(0);">Show</a> </div>
<div id="testDIV" style="height:100px;display:none;background-color:red">DEMO</div>

jQuery

<script type="text/javascript">
          $(document).ready(function(){
            $("#top").click(function(){
                  $("#testDIV").slideDown("slow");
            });
          });
</script>

Demo

Comments are closed.