使用jquery将参数添加到页面上的链接 [英] add parameter to links on page using jquery

查看:98
本文介绍了使用jquery将参数添加到页面上的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jquery向我页面上的所有链接添加类似 ajax = 1 的内容。我还需要检查url是否有现有参数。例如 http://example.com/index.php?pl=132 必须变为 http://example.com/index。 php?pl = 132& ajax = 1

How do I add let's say something like ajax=1 to all links on my page with jquery. I will also need to check if the url has existing parameters. for example http://example.com/index.php?pl=132 will have to become http://example.com/index.php?pl=132&ajax=1

此外,如果链接没有任何参数,例如 http://example.com/index.php ,它将变为 http://example.com/index.php?ajax=1 我想在文档就绪上加载jQuery脚本,以便在页面加载时更改所有链接。

Also, if the link does not have any parameters, for example http://example.com/index.php, it will become http://example.com/index.php?ajax=1 I want to load the jQuery script on document ready so all links are changed on page load.

推荐答案

如果您对插件,有jQuery 查询字符串对象。这将允许您简单地检查查询字符串中的参数,并在必要时添加更多,删除一些或编辑其他参数。

If you're interested in plugins, there's the jQuery Query String Object. This will allow you simple checking of parameters in the querystring, and if necessary the ability to add more, remove some, or edit others.

这篇关于使用jquery将参数添加到页面上的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆