Berikut akan dijelaskan bagaimana membuat efek slideUp dan slideDown di jQuery.

  1. Pertama-tama siapkan div yang akan dianimasikan dan controlnya :
    <button id=”tampil”>Tampilkan</button>&nbsp;
    <button id=”sembunyi”>Sembunyikan</button>&nbsp;
    <div id=”kutipan”>
    The LORD bless you   and keep you,<br/>
    the LORD make his face shine on you  and be gracious to you,<br/>
    the LORD turn his face toward you and give you peace.
    </div>
  2. Script untuk animasi slideUp dan slideDown adalah :
    $(function(){
        $(‘#tampil’).bind(‘click’,function(){
            $(‘#kutipan’).slideDown();
        });

        $(‘#sembunyi’).bind(‘click’,function(){
            $(‘#kutipan’).slideUp();
        });

    });

  3. Coding lengkapnya adalah :
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
    <html>
    <head>
    <title>Show dan Hide dengan slide</title>
    <script src=”development-bundle/jquery-1.6.2.js”>
    </script>
    <script>
    $(function(){
        $(‘#tampil’).bind(‘click’,function(){
            $(‘#kutipan’).slideDown();
        });

        $(‘#sembunyi’).bind(‘click’,function(){
            $(‘#kutipan’).slideUp();
        });

    });

    </script>
    </head>
    <body>
    <button id=”tampil”>Tampilkan</button>&nbsp;
    <button id=”sembunyi”>Sembunyikan</button>&nbsp;
    <div id=”kutipan”>
    The LORD bless you   and keep you,<br/>
    the LORD make his face shine on you  and be gracious to you,<br/>
    the LORD turn his face toward you and give you peace.
    </div>
    </body>
    </html>

  4. Demonya bisa dilihat di http://aris.proweb.asia/show_hide_slide.html .

Kunjungi www.proweb.co.id untuk menambah wawasan anda.

Animasi slideUp dan slideDown di jQuery
× Ada yang dapat saya bantu ? Available on SundayMondayTuesdayWednesdayThursdayFridaySaturday