append a query string to all url's on a page

this should append the query string test=1 to all url's on this page.

if it works...

make sure its added to document ready.


var qs = 'test=1';
	$('a').each(function() {
    	var href = $(this).attr('href');

    	if (href) {
        	href += (href.match(/\?/) ? '&' : '?') + qs;
        	$(this).attr('href', href);

Other Items in javascript

No Items Found.

Add Comment
Type in a Nick Name here
Page Views

This page has been viewed 205 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
You want to be the best, you MUST put the long yards in! Nothing comes easy in life so stop wishing and start DOING! So many people would rather bitch and moan than help themselves. Dont be one of those negative drainers, start today, make a small change and keep going forwards with this attitude!