views:

1320

answers:

2

There seem to be some problems with tabindex in several browsers so I want to work around these issues using javascript/jquery. Specifically FF3.5 (Mac) doesn't accept tabindex or focus on links at all. I have jquery 1.3.2 and js-hotkeys 0.7.9 running on my website.

I have 4 forms on 1 page which I can switch between using a link. Now when the page loads I what 1 of the links to have the focus using it's id. Then I want to be able to tab between each link to display each form.

Stripped down code looks like this:

HTML

<nav id="postNav">
    <ul> 
     <li class="Nav1"><a href="#">1</a></li>
     <li class="Nav2"><a href="#">2</a></li>
     <li class="Nav3"><a href="#">3</a></li>
     <li class="Nav4"><a href="#">4</a></li>
    </ul>
</nav>

<form class="postForm" id="post1">
</form>

<form class="postForm" id="post2">
</form>

<form class="postForm" id="post3">
</form>

<form class="postForm" id="post4">
</form>

Jquery

$(document).ready(function(){       

    $("#postNav ul li a").click(function(event){
        var postOptionSelected = $(this).parent("li").attr("class").substr(3);
     $("form#post"+postOptionSelected).show();
            $("form.postForm:not(#post"+postOptionSelected+")").hide();
            event.preventDefault();
    });
});
A: 

I think you forgot the "Form" after "post":

    $("form#postForm"+postOptionSelected).show();
    $("form.postForm:not(#postForm"+postOptionSelected+")").hide();
Luca Matteis
thanks - corrected
EddyR
+2  A: 

This isn't a Firefox issue. It's a system setting for Mac OS. In System Preferences, Keyboard & Mouse, and Keyboard Shortcuts, there's a Full keyboard access setting that allows users to configure whether they want Tab to enable changing keyboard focus to text boxes and lists only or to all controls. It is set to text boxes and lists only by default.

Safari on Mac OS has a setting in Safari, Preferences, Advanced, Press Tab to highlight each item on a webpage to override this behavior.

Joe Chung
that's fine but I still want to override this... I mean I don't think I would want to suggest to users "please change your settings" when it should just work instead
EddyR