Receive query string
var queryString = window.location.search;
Eliminate ? from the start of the query string
queryString = queryString.substring(1);
Query string handler
var parseQueryString = function( queryString ) {
var params = {}, queries, temp, i, l;
// Break down into key/value pairs
queries = queryString.split("&");
// Convert the array of strings into an object
for ( i = 0, l = queries.length; i < l; i++ ) {
temp = queries[i].split('=');
params[temp[0]] = temp[1];
}
return params;
};
// Query string object
var pageParams = parseQueryString(queryString);
// CSS variables
var target = pageParams.target;
var prop = pageParams.prop;
var value = pageParams.value;
// Unable to get it working -->
jQuery(target).css({
prop : value,
});
I aim to input a query similar to this "?target=body&prop=display&value=none" and hide the whole body or target specific elements by their class.