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

26,912

Solution 1

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

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

Solution 2

myfunction must be defined!

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

setTimeout(function(){
            myfunction();
         },300);
})
Share:
26,912

Related videos on Youtube

Admin
Author by

Admin

Updated on May 13, 2020

Comments

  • Admin
    Admin almost 4 years

    I want to fire a event on keyup of 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

Related