我正在尝试选择 tabindex 大于 -1 的所有元素(可聚焦元素)。到目前为止,这是我想出的:
$element.find('[tabindex]:not([tabindex < \'0\'])');
它不起作用,而是抛出错误:
Error: Syntax error, unrecognized expression: [tabindex < '0']
at Function.Sizzle.error (vendor.js:1463)
...
但是,这可以工作,但不涵盖 tabindex < -1 的情况。
$element.find('[tabindex]:not([tabindex=\'-1\'])');
最佳答案
Selectors doesn't provide attribute selectors with numeric comparisons ,jQuery 也没有。
在这种特定情况下,我想您可以排除 tabindex 以 -
符号开头的元素(除了排除 tabindex 为 0 的元素之外):
$element.find('[tabindex]:not([tabindex="0"]):not([tabindex^="-"])');
关于jquery - "tabindex > 0"元素的 CSS 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39447657/