javascript - Show div for a moment then switch to another div in jquery -


i'm trying make animation jquery 1.9.1 want show div short moment switch defualt div @ button click. far i've tried using show() & hide() method. nothing working. here codes,

<script>     $(document).ready(function (){         $('#btnchange').click(function () {             $('#red').hide();             $('#blue').show().delay(1500).hide();             $('#red').show();         });     }); </script> 

jsfiddle demo here

how can show div moment , after switch default div #red @ button click? neec badly. thanks!

if set duration .hide( [duration ] [, complete ] ) method, it'll placed in fx queue , delay work:

you should stop() previous animation better handling multiple clicks btw

$(document).ready(function (){     $('#btnchange').click(function () {         $('#red').hide();         $('#blue')/*.stop()*/.show().delay(1500).hide(0);         $('#red').show();     }); }); 

-jsfiddle-

with .stop():

-jsfiddle-


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -