jQuery的过滤器由一个属性值 [英] jQuery filter by an attribute value

查看:103
本文介绍了jQuery的过滤器由一个属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div class="selectedColumns" >
<a href="#" attributeid="19" >Driver License State</a>
<a href="#" attributeid="21" >Email</a>
<a href="#" attributeid="23" >Experience Level</a>
<a href="#" attributeid="26" >First Name</a>
<a href="#" attributeid="71" >Is Account Enabled</a>
<a href="#" attributeid="39" >Last Contacted Date</a>
<a href="#" attributeid="40" >Last Name</a>
<a href="#" attributeid="41" >Middle Name</a>
<a href="#" attributeid="6">Carrier</a>
</div>

我有链接的集合。每个环节都有一个attributeid财产。我想根据属性值进行过滤。所以在上面,如果我有41值的链接它会返回中间名链接。

I have a collection of links. Each link has an attributeid property. I would like to filter by attribute value. So in the links above if I have a value of 41 it would return the Middle Name link.

var link = $('.selectedColumns a:[attributeid==' + $(this).val() + ']');

这不工作?

推荐答案

使用的2.单=代替此外,:shoudn't在那里AFAIK

use a single = instead of 2. Also, the : shoudn't be there afaik

var link = $('.selectedColumns a[attributeid=' + $(this).val() + ']');

这篇关于jQuery的过滤器由一个属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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