Get URL parameters using jQuery

jQuery code snippet to get the dynamic variables stored in the url as parameters and store them as JavaScript variables ready for use with your scripts. $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); return results[1] || 0; } // example.com?param1=name&param2=&id=6 $.urlParam('param1'); // name $.urlParam('id'); // 6 $.urlParam('param2'); // null //example…