HTML5:如何在点击其中任何一个链接后禁用所有链接? [英] HTML5: how do I disable all links after any one of them are clicked?

查看:114
本文介绍了HTML5:如何在点击其中任何一个链接后禁用所有链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我目前的链接:

< a href =/ board / take_turn?id = 313& x = 1& y = 2data-remote =trueclass =square>
< span class =ttt_square>
& nbsp;
< / span>
< / a>

我知道它不是ajax,因为jQuery ajax:成功类型事件永远不会被调用。

I know it's not ajax because the jQuery ajax:success type events are never invoked.

这是我正在处理的网站: http: //ttt-ai.heroku.com/

This is teh site that I'm working on: http://ttt-ai.heroku.com/

推荐答案

试试这个,

<script type="text/javascript">
    $(function() {
        $('a').click(function() {
           $(this).attr('href', 'javascript:void(0);');
        });
    });
</script>

如果你要为你的链接添加一个类来更具体;让我们说

And if you will add a class to your link for being more specific; let's say

<a class="disableAfterClick" href="/board/take_turn?id=313&x=1&y=2" data-remote="true"> <span class="ttt_square"> &nbsp; </span> </a>

<script type="text/javascript">
    $(function() {
        $('a.disableAfterClick').click(function() {
           $(this).attr('href', 'javascript:void(0);');
        });
    });
</script>

这篇关于HTML5:如何在点击其中任何一个链接后禁用所有链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆