0

I have a 5 panel multi step form that uses divs 'previous' and 'next' to navigate through. I would like to make it so hitting a left arrow key acts as clicking the previous button, but hitting the right arrow key will act as hitting right.

I have this working.. Sort of.

I have bind(ed) my arrow keys correctly, but since it's going off of class name, it wants to tab through every single one of them. Is there a way to do it so it only activates the one that is on the <fieldset> currently displaying?

<input type="button" name="previous" class="previous action-button" value="Previous" />

//binds left/right for navigation
$(window).bind('keydown', function(e){

    if (e.keyCode==37) {
        $(".previous").trigger("click");
    } else if (e.keyCode==39) {
        $(".next").trigger("click");
    };
});
knocked loose
  • 3,142
  • 2
  • 25
  • 46

1 Answers1

0

Since everything is working already. I would suggest
to have a different class name, for your particular interested elements, & trigger click on them only
so that it does tab only those.

Best of luck.

(Mark this as answer if it serves your need)

Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140