How to get the value from the GET parameters using jQuery?
Very often we face challenge need get values from URL (GET query parameters) and if in PHP is a special function ($_GET) then in JavaScript and in particular jQuery such function is absent. Below, I’ll provide example that function, that I found in the Network.
Problem: How to get the value from the GET parameters using jQuery?
Solution:
// Get Url Parameter From URL
function getUrlParameter( name, url ) {
if ( !name ) {
return;
} else {
var url = (url) ? url : window.location.href;
var results = new RegExp( '[\?&]' + name + '=([^&#]*)' ).exec( url );
return results[1] || 0;
}
}
Source: