如何使用 jQuery 检测 URL 更改 [英] How to detect URL changes with jQuery
本文介绍了如何使用 jQuery 检测 URL 更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery 如何检测 url 的变化?
How can jQuery detect changes to a url?
例如:如果用户转到页面 site.com/faq/
什么都没有显示,但是如果他转到 site.com/faq/#open
jquery检测到它并做一些事情.
For example: If a user goes to a page site.com/faq/
nothing shows, but if he goes to site.com/faq/#open
jquery detects it and does something.
推荐答案
试试这个
$(window).on('hashchange', function(e){
// Your Code goes here
});
它对我有用
这篇关于如何使用 jQuery 检测 URL 更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文