我是 Jquery 新手,并且一直在寻找此问题的解决方案一段时间 - 我在 Jquery 文件顶部使用以下内容来限制仅在主页上工作
if (top.location.pathname === '/')
{
如何更改它以使其也适用于/About 页面?
提前致谢!
最佳答案
你只需要这样做
if (top.location.pathname === '/' || top.location.pathname ==='/About' )
{
// Your code goes here
}
关于javascript - 如何告诉 jQuery 仅在两个特定网页上运行某个函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25006531/