简体   繁体   中英

Add timing of jquery

I need help adding a 2-second delay to the load of the below;

<script>
$(document).ready(function() {
     $.magnificPopup.open({items: {src: '#my-form'},type: 'inline'}, 0);
});

</script>

This should work.

    <script>
       $(document).ready(function() {
         setTimeout(function(){ $.magnificPopup.open({items: {src: '#my-form'},type: 'inline'}, 0); }, 2000);
       });
    </script>

You can use the native setTimeout function in JavaScript and apply your function as a callback:

<script>
    $(document).ready(function () {
        setTimeout($.magnificPopup.open({items: {src: '#my-form'},type: 'inline'}, 0),2000);
    });
</script>    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM