如何使用jQuery选择具有特定ARIA值的所有元素? [英] How to select all elements with particular ARIA value using jQuery?

查看:463
本文介绍了如何使用jQuery选择具有特定ARIA值的所有元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于我有一个示例页面,如下所示:

Given i have a sample page that looks like this:

<!DOCTYPE html>
<html>
<body>

<h1 aria-controls="name1">heading</h1>

<p aria-controls="name2">paragraph</p>

<span aria-controls="name1">span</span>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>

我将如何使用jQuery选择其aria-controls属性设置为name1的(2)个元素? (忽略元素类型不同的事实).

How would i use jQuery to select the (2) elements with their aria-controls attribute set to name1? (ignoring the fact that the element types are different).

谢谢!

推荐答案

属性选择器

[aria-controls="name1"]

应该工作.

文档: http://api.jquery.com/attribute-equals-selector/

这篇关于如何使用jQuery选择具有特定ARIA值的所有元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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