views:

218

answers:

1

I have a jQuery statement that's working fine. How would I re-write it in .live?

 $(document).ready(function()
 {

    $(':input:enabled:visible, a:enabled:visible, span.ValidatorClass').each
    (function(i, e) { $(e).attr('tabindex', i) });


  });

The reason I need this is I hide/show elements sometimes using .show and .hide and when that happens I need to reset tab order for the elements that appear/disappear.

+1  A: 

Showing and hiding elements raises no events as far as I know, so live won't help you here.

However, since you don't add new elements nor reorder them, you can set the correct tabindex right from the start. The browser will ignore hidden or disabled elements anyway. Run your code without the :visible and enabled filters:

$(':input, a, span.ValidatorClass')
 .each(function(i, e) { $(e).attr('tabindex', i) });
Kobi
Thanks for the help
Victor