如何使用多个“属性等于"jquery中的选择器? [英] How to use multiple "Attribute Equals" selector in jquery?

查看:48
本文介绍了如何使用多个“属性等于"jquery中的选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你想选择一个具有等于一个值的 1 个属性的 jquery 元素很简单:

If you want to select a jquery element with 1 attribute that equals a value is simple:

$(".element[attribute1='true']").hide();

但是如果您想选择具有 2 个相同属性的元素怎么办?

But what if you want to select an element with 2 equal attributes?

$(".element[attribute1='true', attribute2='false']").hide();

那行不通.

推荐答案

您可以使用多个 属性等于选择器 [name="value"] 在 jquery 中类似于底部代码:

You can use multiple Attribute Equals Selector [name="value"] in jquery like bottom code:

$(".element[attribute1='true'][attribute2='false']").hide();

这篇关于如何使用多个“属性等于"jquery中的选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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