且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery如何检查url是否包含单词?

更新时间:2022-03-13 07:13:00

尝试:

if (window.location.href.indexOf("catalogue") > -1) { // etc

indexOf不返回true/false,它返回搜索字符串在字符串中的位置;或-1(如果找不到).

indexOf doesn't return true/false, it returns the location of the search string in the string; or -1 if not found.