根据部分href选择链接 [英] Select link based on partial href

查看:153
本文介绍了根据部分href选择链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery中是否有一个选择器,允许我选择所有以href="/products/index?page="开头的href的锚标记?

Is there a selector in jQuery that will allow me to select all anchor tags that have a href beginning with href="/products/index?page="?

我的完整href是href="/products/index?page=2",但是他们都有共同的开始.

My full href is href="/products/index?page=2", but they all have the beginning in common.

推荐答案

您可以使用使用属性选择器开始,如下所示:

You can use the starts-with attribute selector, like this:

$("a[href^='/products/index?page=']")

如果您感到好奇,可以使用其他属性选择器也是

In case you're curious, there are other attribute selectors available as well.

这篇关于根据部分href选择链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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