[英]Use jQuery to navigate away from page
I will only have a relative link available to me but I want to use jQuery to navigate to this rel link. 我只会有一个相对链接,但我想使用jQuery导航到这个rel链接。 I only see AJAX functionality in jQuery. 我只在jQuery中看到AJAX功能。 How can I do this using jQuery or just pure HTML/JavaScript? 我怎么能用jQuery或纯HTML / JavaScript做到这一点?
window.location.href = "/somewhere/else";
你不需要jQuery,简单的window.location代码会这样做,例如:
window.location.href = myUrl;
Other answers rightly point out that there is no need to use jQuery in order to navigate to another URL; 其他答案正确地指出,没有必要使用jQuery导航到另一个URL; that's why there's no jQuery function which does so! 这就是为什么没有jQuery函数这样做的原因!
If you're asking how to click a link via jQuery then assuming you have markup which looks like: 如果您正在询问如何通过jQuery单击链接,那么假设您有标记,如下所示:
<a id="my-link" href="/relative/path.html">Click Me!</a>
You could click()
it by executing: 您可以通过执行以下命令来click()
它:
$('#my-link').click();
window.location = myUrl;
无论如何,这不是jQuery:它是简单的javascript
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.