jquery - javascript delay and show gif -
do know how can implement javascript delay animated gif when button clicked? have button click functionality, want add together 2 sec delay, gif. here working javascript, without delay. give thanks you.
$(function() { $('#mybutton').click(function () { $('#myframe').attr('src', '/video/upload.aspx/'); $('#myframe').attr('width', '500'); $('#myframe').attr('height', '200'); $('#vid').hide(); $('#vid2').show(); $('#myframe').show(); }); });
i tried this, , didn't work:
$(function openvideo() { $('#mybutton').click(function () { $('#myframe').attr('src', '/video/upload.aspx/'); $('#myframe').attr('width', '500'); $('#myframe').attr('height', '200'); $('#vid').hide(); $('#vid2').show(); $('#myframe').show(); }); }); settimeout(openvideo, 2000);
use javascript settimeout function:
function functionname() { // stuff. } settimeout(functionname, 2000);
or this:
settimeout(function() { // stuff. }, 2000);
in illustration might this:
$(function openvideo() { $('#mybutton').click(function () { var delay = settimeout(function() { $('#myframe').attr('src', '/video/upload.aspx/'); $('#myframe').attr('width', '500'); $('#myframe').attr('height', '200'); $('#vid').hide(); $('#vid2').show(); $('#myframe').show(); }, 2000); }); });
demo javascript jquery settimeout
No comments:
Post a Comment