I am trying to select all the elements which has tabindex greater than -1 (focus-able elements). So far this is what I came up with:
$element.find('[tabindex]:not([tabindex < \'0\'])');
It does not work but instead throws an error:
Error: Syntax error, unrecognized expression: [tabindex < '0']
    at Function.Sizzle.error (vendor.js:1463)
...
This, however, works but itdoes not cover cases where tabindex < -1.
$element.find('[tabindex]:not([tabindex=\'-1\'])');
Selectors doesn't provide attribute selectors with numeric comparisons, and neither does jQuery.
In this specific case, I suppose you could just exclude elements with a tabindex starting with the - sign (in addition to excluding elements with a tabindex of 0):
$element.find('[tabindex]:not([tabindex="0"]):not([tabindex^="-"])');
You can use a filter for this:
$("[tabindex]").filter(function() {
    return parseInt($(this).attr("tabindex"), 10) >= 0;
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With