I am trying to use jQuery UI :tabbable to select the next and previous input elements on a page. I have the following html
<div id="section1">1. <input type="text" />2. <input type="text" /> </div> <div id="section2">3. <input type="text" />4. <input type="text" />5. <input type="text" /> </div>
and next javascript
$(document).ready(function () { $("input").on("keyup", function (event) { if (event.keyCode == 40) $(this).next(":tabbable").focus(); else if (event.keyCode == 38) $(this).prev(":tabbable").focus(); }); });
The selector seems to work fine in a div. For example, if I am at input 3 and press down, it will go to input 4. However, if I press, the selector cannot find input 2. I cannot figure out how to find the previous tabbable on the page.
Jsfiddle example
Danny source share