On 25/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Guys i am having some problems with my NEW plugin (yes another one :p) > > Is it possible to search backwards from the current element? > > To be specific, i need to find the first VISIBLE (e.g. not hidden by css > or not type="hidden") and FOCUSABLE element before element i am basing my > search of. > > A pseudo example: > ----------------- > <input text> > <input hidden> > <input hidden> > <input hidden> > <checkbox> (hidden by css) > <label> > > User is focused on the label, and presses SHIFT+TAB, normally it would set > the focus on the checkbox. But since i have coded a custom .focus() > function on that AND it is hidden, i need to set the focus to the text > input. > > I came up with this, but that wouldn't work :0 > jQuery('input:eq(-2)').is(':visible)[0]; > > Any tips if this is even possible?
I think reverse (and other array method) will be an option in a future version (perhaps 1.1). But in the meantime, check out this (demo of a post made a while ago about using each backwards): http://www.texotela.co.uk/code/jquery/reverse/ jQuery('input:visible').reverse().eq(1)[0] Returns the second to last visible input (eq(0) being the last) _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/