jQuery的选择有一个ACCESSKEY定义的所有元素有一个、元素、定义、jQuery

2023-09-04 01:06:47 作者:大六汉子

我要选择那些对他们定义的ACCESSKEY所有元素。

I want to select all elements that have an accesskey defined on them.

我知道我可以做到这一点: $('[ACCESSKEY]'),但是这给了我很大的投入,的HREF等,在页面上(大多数情况他们有一个空的ACCESSKEY)。

I know that i can do this: $('[accesskey]'), but that gives me lot of inputs, hrefs etc, on the page (most of them have an empty accesskey).

有什么办法只选择其中ACCESSKEY实际上有一个值的元素?

What is the way to select only the elements where the accesskey actually has a value?

编辑:我找到的空accesskeys事业为好,由一些老禁用/恢复accesskeys JavaScript通过多模态对话框功能。。通常你不会得到这么多的元素与空accesskeys引起

推荐答案

通过一个选择:

$('[accesskey][accesskey!=""]').foo

它是如何工作的:

How does it work:

// Has the accesskey attribute defined.
[accesskey]

// Doesn't have an empty value for the accesskey attribute.
[accesskey!=""]

再加它选择其中具有 ACCESSKEY 属性的每一个元素,它不是空的。

Together it select every element which has the accesskey attributes and it's not empty.