本文介绍了jQuery的选择有一个ACCESSKEY定义的所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要选择那些对他们定义的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?

推荐答案

通过一个选择:

$('[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.

这篇关于jQuery的选择有一个ACCESSKEY定义的所有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:45