Question

I want my links not to have the weird outline and the best way I found to solve this is have a "null link" to focus on after a click. This works great when defining the onclick method inline the HTML but that is not ideal. I wrote a quick jQuery snippet to do this instead, but I am having trouble getting it to work. Here it is:

<script type="text/javascript" charset="utf-8">
    $j(document).ready(function () {
        //alert($j('#ml_table thead a').length);
        $j('#ml_table thead a').click( function (){
            $j('#null_link').focus(); return false;
        });
    });
</script>

Does anyone see any problems with this? The alert spits out 8 which is the correct number of anchor elements so I know the selector is working properly. The jQuery docs say that I don't have to iterate through the array of elements.

Thanks!

Was it helpful?

Solution

Try css:

#ml_table thead a {
    outline:none;
}

And for IE:

$('#ml_table thead a').attr('hidefocus', true)

References:

But yeah, to answer your direct question the one click function is applied to the 8 anchors it found.

That focus trick looks kinda funky. If you really want to keep it you can try instead:

$j('#ml_table thead a').click(function () {
    $(this).blur();
    return false;
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top