Execute jquery after page load

I am facing the following problem:

On a webpage  page1 I have to click on a link.The second page opens on the same container (the link does not change plz check the photos)page2.

On the second page I have to execute some jquery. I am trying the following code:

`   $(document).ready(function(){
   $("a").click(function(event){
     alert("Thanks for visiting!");
        var vr1= document.getElementsByClassName("hc-inline-block hc-px1 hc-rounded hc-white")[0].innerText;
        alert("vr1 is: " + vr1);

    });

 });`

The problem of this code is that it gets executed after the link is clicked but before the second page is loaded. This makes the class unavaiable...

Is there anyway I can execute some Jquery after the second page is fully loaded???

1 answer

  • answered 2022-01-20 08:06 Alduxo

    SetTimeout function worked on my case.

    setTimeout(function() {
    
        // do stuff here
    
    }, 1000);
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum