Javascript examples for jQuery:String
Set query string to all links
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(function(){/*from www. jav a 2 s .c o m*/ var querystring = 'myquerystringtoadd'; $('a').each(function() { var href = $(this).attr('href'); href += (href.match(/\?/) ? '&' : '?') + querystring; $(this).attr('href', href); }); }); </script> </head> <body> <a href="url.html?abc=def">1</a> <a href="url.html">2</a> </body> </html>