且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过jQuery中的href获取元素?

更新时间:2022-03-25 00:33:55

是的,您可以使用jQuery的

Yes, you can use jQuery's attribute selector for that.

var linksToGoogle = $('a[href="http://google.com"]');

或者,如果您的兴趣是使用某个网址链接开始使用属性开始选择器:

Alternatively, if your interest is rather links starting with a certain URL, use the attribute-starts-with selector:

var allLinksToGoogle = $('a[href^="http://google.com"]');