Hi Klaus, thanks for your effort. I tried your code and it works. But, there still is a problem.
When I click one of these links it only outputs the query parameter of the first link. No matter which link I click I always get the value first one. Any way to change this? Regards, Johannes Klaus Hartl wrote: > I meant a parameter like this: index.php?foo=bar&something=else > > Here's a little helper to extract such parameters: > > jQuery.query = function(s) { > var r = {}; > if (s) { > var q = s.substring(s.indexOf('?') + 1); // remove everything > up to the ? > q = q.replace(/\&$/, ''); // remove the trailing & > jQuery.each(q.split('&'), function() { > var splitted = this.split('='); > var key = splitted[0]; > var val = splitted[1]; > // convert numbers > if (/^[0-9.]+$/.test(val)) val = parseFloat(val); > // convert booleans > if (val == 'true') val = true; > if (val == 'false') val = false; > // ignore empty values > if (typeof val == 'number' || typeof val == 'boolean' || > val.length > 0) r[key] = val; > }); > } > return r; > }; > > Usage: > > var params = $.query( $('a').attr('href') ); // { foo: 'bar', something: > 'else'} > alert(params.foo); // 'bar' -- View this message in context: http://www.nabble.com/Get-a-parameter-from-a-link-tf3165936.html#a8783563 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/