jQuery:将querystring附加到所有链接 [英] Jquery : Append querystring to all links
本文介绍了jQuery:将querystring附加到所有链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将查询字符串附加到页面内的所有动态链接上-修复旧版本中的错误-这可能吗?
I would like to append a query string onto all dynamic links within a page - to fix a bug in a old release - is this possible?
有什么想法吗?
推荐答案
像这样吗?
var querystring = 'myquerystringtoadd';
$('a').each(function() {
var href = $(this).attr('href');
if (href) {
href += (href.match(/\?/) ? '&' : '?') + querystring;
$(this).attr('href', href);
}
});
这篇关于jQuery:将querystring附加到所有链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文