How to call a jquery function onload with some delay?

前端 未结 5 787
闹比i
闹比i 2021-01-23 21:53

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(         


        
5条回答
  •  孤街浪徒
    2021-01-23 22:12

    Try it like this..

    $(document).ready(function () {
    setTimeout(function () {
    $(".sample").live('click',function(){
    var id=$(this).attr("id");
       }, 3000);
    }, 3000);
    

    This will fire on page load after 3 seconds delay.

提交回复
热议问题