This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18429|Reply: 1

[Jquery] jQuery gets the URL parameter value extension

[Copy link]
Posted on 2021-2-24 11:05:10 | | | |
Get the browser URL parameter value
https://www.itsvse.com/thread-8423-1-1.html
Previously, js was used to obtain the URL parameter value, and the regular expression matched the content of "location.href", but this article encapsulates jQuery to obtain the URL parameter value, which is more accurate by matching window.location.search.

The renderings are as follows:



Code:







Previous:jQuery intercepts the results returned by Ajax
Next:.NET Core Chinese Character Generation Pinyin Solution
 Landlord| Posted on 2022-11-21 22:03:36 |
2022 new syntax, native js query url parameters



var paramsString = "q=URLUtils.searchParams&topic=api"
var searchParams = new URLSearchParams(paramsString);

for (let p of searchParams) {
  console.log(p);
}

searchParams.has("topic") === true; // true
searchParams.get("topic") === "api"; // true
searchParams.getAll("topic"); // ["api"]
searchParams.get("foo") === null; // true
searchParams.append("topic", "webdev");
searchParams.toString(); // "q=URLUtils.searchParams&topic=api&topic=webdev"
searchParams.set("topic", "More webdev");
searchParams.toString(); // "q=URLUtils.searchParams&topic=More+webdev"
searchParams.delete("topic");
searchParams.toString(); // "q=URLUtils.searchParams"


URLSearchParams:The hyperlink login is visible.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com