【发布时间】:2020-04-09 20:20:34
【问题描述】:
我希望能够检查 url 是否包含单词 catalogue。
这就是我正在尝试的......
$(document).ready(function () {
if (window.location.href.indexOf("catalogue"))
{
$("#trail").toggle();
}
});
网站的网址可以是..
http://site.co.uk/catalogue/
或者
http://site.co.uk/catalogue/2/domestic-rainwater.html
等等
但它不起作用。有人可以指出我哪里出错了吗?
【问题讨论】:
-
将 if (window.location.href.indexOf("catalogue")) 更改为 if (window.location.href.indexOf("catalogue") > -1)
标签: javascript jquery