Summarize some common frontend JQ operations (improved slowly) and frontend jq
1. instantiate a Js object and use it as a class. The example is a url parameter.
Function GetRequestCondition () {var url = window. location. href; var conditon = url. substring (url. indexOf ("? ") + 1, url. length); var strs = conditon. split ("&"); var theRequest = new Object (); for (var I = 0; I <strs. length; I ++) {theRequest [strs [I]. split ("=") [0] = decodeURI (strs [I]. split ("=") [1]); // you must use the decodeURI () function to decode the URI encoded by the encodeURI () function. } Return theRequest;} var Request = new Object (); Request = GetRequestCondition (); $ ("# OrderID "). val (Request ["OrderID"]); $ ("# TraderName "). val (Request ["TraderName"]); $ ("# MallName "). val (Request ["MallName"]); $ ("# Contacts "). val (Request ["Contacts"]);
2. Method for replacing the value of the specified parameter in the URL
function replaceParamVal(oldUrl, paramName, value) { var reg = eval('/(' + paramName + '=)([^&]*)/gi'); var newUrl = oldUrl.replace(reg, paramName + '=' + value);return newUrl; }