Use jQuery to navigate away from page

后端 未结 3 594
青春惊慌失措
青春惊慌失措 2021-02-01 01:53

I will only have a relative link available to me but I want to use jQuery to navigate to this rel link. I only see AJAX functionality in jQuery. How can I do this using jQuery

相关标签:
3条回答
  • 2021-02-01 02:16
    window.location.href = "/somewhere/else";
    
    0 讨论(0)
  • 2021-02-01 02:27

    Other answers rightly point out that there is no need to use jQuery in order to navigate to another URL; that's why there's no jQuery function which does so!

    If you're asking how to click a link via jQuery then assuming you have markup which looks like:

    <a id="my-link" href="/relative/path.html">Click Me!</a>
    

    You could click() it by executing:

    $('#my-link').click();
    
    0 讨论(0)
  • 2021-02-01 02:28
    window.location = myUrl;
    

    Anyway, this is not jQuery: it's plain javascript

    0 讨论(0)
提交回复
热议问题