简体   繁体   中英

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

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

in js using jquery library.

I want this to catch "Default.asp" as well as "DeFaULT.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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM