开发者

how i can execute a jQuery function after a time period when event fire in jQuery?

I want to fire a event on keyup 开发者_StackOverflowof textbox 300 milisecond later

$("#blah").keyup(function () {
               //code is here
            }).delay(300).myfunction();

when i try to execute this function i found error that myfunction is not a function.

so can anyone explain how i can execute a function 300 milisecond later after keyup in a textbox


function myFunction () {
    // Code to do stuff after 300ms
}

$("#blah").keyup(function () {
               // Code to do stuff immediately
               setTimeout(myFunction, 300);
            });


myfunction must be defined!

$("#blah").keyup(function () {

setTimeout(function(){
            myfunction();
         },300);
})


As docs say, from version 1.4 on-wards, you can use delay() function

$( "#foo" ).slideUp( 300 ).delay( 800 ).fadeIn( 400 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜