jquery - Show and hide effect of div element -


i have div should hidden initially. on event (doesn't matter) want div slide up, stay several seconds , slide down again. how achieve this.

you can use slideup(), slidedown() , delay()

function anim() {    $('div')      // stop previous animation      .stop()      // slide div      .slideup()      // wait 2 seconds      .delay(2000)      // slide down div      .slidedown();  }    anim();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <div style="height:100px;width:100px;background:black"></div>


or using settimeout() instead of delay()

function anim() {    var $div = $('div')      // stop previous animation      .stop()      // slide div      .slideup();    // wait 2 seconds    settimeout(function() {      // slide down div      $div.slidedown()    }, 2000);  }    anim();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <div style="height:100px;width:100px;background:black"></div>


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -