Seetha Raman Seetha Raman - 1 month ago 10
jQuery Question

How to call a jquery function onload with some delay?

How to call a jquery function onload with some delay?

I want to call a function like this on load with some delay

$(".sample").live('click',function(){
var id=$(this).attr("id");

Answer

This will wait 1 second and then assign the event handler...

function assignSampleClick() {
    $(".sample").live('click',function(){
        var id=$(this).attr("id");
    });
}

// document ready
$(function() {
    setTimeout(assignSampleClick, 1000);
});