开发者

How to ignore uppercase/lowercase when selecting pathname? JS/Jquery

开发者 https://www.devze.com 2023-01-02 10:32 出处:网络
if (pathname == \"/\" || pathname == \"/default.asp\") in js using jquery library. I want this to catch \"Default.asp\" as well as \"DeFa开发者_如何转开发ULT.asp\" and \"default.asp\"
if (pathname == "/" || pathname == "/default.asp")

in js using jquery library.

I want this to catch "Default.asp" as well as "DeFa开发者_如何转开发ULT.asp" and "default.asp"

halp.


Use the string.toLowerCase() method, this is base javascript, no jQuery needed:

pathname = pathname.toLowerCase();
if (pathname == "/" || pathname == "/default.asp") {
  //case in-sensitive math!
}


I believe this might work:

if (pathname == "/" || pathname.toLowerCase() == "/default.asp")

0

精彩评论

暂无评论...
验证码 换一张
取 消