jQuery 中怎么跳转页面? 下面本篇文章给大家介绍一下. 有一定的参考价值, 有需要的朋友可以参考一下, 希望对大家有所帮助.
首先我们来看看 JavaScript 中是怎么跳转页面的.
1, 我们可以利用 http 的重定向来跳转
Windows.location.replace("http://www.html.cn");
2, 使用 href 来跳转
Windows.location.href = "http://www.html.cn";
下面我们来看看 jQuery 中是怎么跳转页面的.
使用 jQuery 的属性替换方法
- $(location).attr('href', 'http://www.html.cn');
- $(Windows).attr('location','http://www.html.cn');
- $(location).prop('href', 'http://www.html.cn')
可以看出, 通过 jQuery 操作 location 对象, 并调用 attr() 或 prop() 方法, 把 href 属性赋值为新的 url 地址就行了.
更多前端开发 https://www.html.cn/ 知识, 请查阅 HTML 中文网 !!
来源: http://www.css88.com/qa/jquery/17082.html