开发者

JQuery click function not being set

开发者 https://www.devze.com 2022-12-08 21:48 出处:网络
I want my links not to have the weir开发者_开发技巧d 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

I want my links not to have the weir开发者_开发技巧d 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!


Try css:

#ml_table thead a {
    outline:none;
}

And for IE:

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

References:

  • hideFocus

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;
})
0

精彩评论

暂无评论...
验证码 换一张
取 消