Great Question Great Question - 1 year ago 125
jQuery Question

CSS selector for "tabindex > 0" elements

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.


Answer Source

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):

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download