简体   繁体   中英

how the browser execute this javascript code: window.location.href=“url”

  $("#retrieve-cancel-reservation").click(function(){
       window.location.href="reservation.php?action_type=retrieve";
       $('#reservation_bar').css('display','none')
   });

there is div,id=reservation_bar in the redirect link page. But $('#reservation_bar').css('display','none') have no effect at the end. It seems that i make mistakes about how the javascript code to execute .

**Does anyone can explain how the browser execute those code above?

Why the display=none is ont work? thanks a lot.**

I don't think you can alter the CSS of another page, which is essentially what you are doing. I would keep the window.location redirect, and then hide $('#reservation_bar') on the new page on load. Include this on the new page:

$( document ).ready(function() {
    $('#reservation_bar').css('display','none');
});

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