Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我如何告诉jQuery只在两个特定的网页上运行函数?_Javascript_Jquery - Fatal编程技术网

Javascript 我如何告诉jQuery只在两个特定的网页上运行函数?

Javascript 我如何告诉jQuery只在两个特定的网页上运行函数?,javascript,jquery,Javascript,Jquery,我是Jquery新手,一直在寻找这个问题的解决方案- 我在Jquery文件的顶部使用以下命令来限制只在主页上工作 if (top.location.pathname === '/') { 我如何将其更改为同时在/About页面上工作 提前谢谢 你只需要这样做 if (top.location.pathname === '/' || top.location.pathname ==='/About' ) { // Your code goes here }

我是Jquery新手,一直在寻找这个问题的解决方案- 我在Jquery文件的顶部使用以下命令来限制只在主页上工作

   if (top.location.pathname === '/') 

        {
我如何将其更改为同时在/About页面上工作


提前谢谢

你只需要这样做

if (top.location.pathname === '/' || top.location.pathname ==='/About' ) 
{
     // Your code goes here
}

听起来您想使用“或”,希望OP没有查询字符串真是太好了,我已经胡闹了好几个小时了!(结束了漫长的一天),谢谢allot@user3572895你应该把这个答案标记为正确。