How do I load jquery snippets after full load of html?

Is there any way to load these snippets after full load of html? I'd be very happy if loading the snippets after the js file (set to ASYNC load) or even set a timer.

<script>$(document).ready(function(){var modals = ['#bookings', '#studios', '#mygallery', '#social', '#reviews', '#articles', '#contactme', '#credits', '#pagemap', '#tsandcs', '#events'];if (window.location.hash && ~modals.indexOf(window.location.hash)) {$(window.location.hash).modal();}})</script>
<script>$(document).ready(function(){$("#myModal11").modal('show');});</script>
<script>$(".modal:not(.noclose) a").click(function(){$(this).closest(".modal").modal("hide");});</script>

Answers 1

  • You can try this Behaviour
    Hope this helps !

    <html>
    <head>
    
    </head>
    <body>
    
    // My Html Here
    
    <script>
    $(document).ready(function(){
    var modals = ['#bookings', '#studios', '#mygallery', '#social', '#reviews', '#articles', '#contactme', '#credits', '#pagemap', '#tsandcs', '#events'];
        if (window.location.hash && ~modals.indexOf(window.location.hash)) {
            $(window.location.hash).modal();
        }
    
    $("#myModal11").modal('show');
    
    $(".modal:not(.noclose) a").click(function(){
        $(this).closest(".modal").modal("hide");
        });
    });
    
    </script>
    </body>
    

    // And Remove this click function and use .on instead of it for single handler

    $(".modal:not(.noclose)").on("click","a",function(){
        $(this).closest(".modal").modal("hide");
        });
    });
    

Related Articles