admin管理员组文章数量:1425663
This is what my current link looks like:
<a href="/board/take_turn?id=313&x=1&y=2" data-remote="true" class="square">
<span class="ttt_square">
</span>
</a>
I know it's not ajax because the jQuery ajax:success type events are never invoked.
This is teh site that I'm working on: /
This is what my current link looks like:
<a href="/board/take_turn?id=313&x=1&y=2" data-remote="true" class="square">
<span class="ttt_square">
</span>
</a>
I know it's not ajax because the jQuery ajax:success type events are never invoked.
This is teh site that I'm working on: http://ttt-ai.heroku./
Share Improve this question edited Feb 2, 2011 at 16:29 NullVoxPopuli asked Feb 2, 2011 at 3:45 NullVoxPopuliNullVoxPopuli 65.3k76 gold badges214 silver badges361 bronze badges 2- "all links" = all links in the page? – gianebao Commented Feb 2, 2011 at 3:49
- all links after yes is clicked on the page. each of the square links, a.square – NullVoxPopuli Commented Feb 2, 2011 at 16:31
4 Answers
Reset to default 3If you want to disable all links on a page you can use this:
$("a").live('click', function(e) {
e.preventDefault;
return false;
});
Or you can target specific links like this:
$("a.disabledLink").live('click', function(e) {
e.preventDefault;
return false;
});
<a href="/board/take_turn?id=313&x=1&y=2" data-remote="true" class="disabledLink">
<span class="ttt_square"> </span>
</a>
Try this,
<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"> </span> </a>
than
<script type="text/javascript">
$(function() {
$('a.disableAfterClick').click(function() {
$(this).attr('href', 'javascript:void(0);');
});
});
</script>
You can use e.preventDefault() .
var $a = $("a");
$a.click(function() {
$a.click(function(e) {
e.preventDefault();
}
});
no need to traverse twice, or if you do
$("a").live("click", function() {
$("a").click(function(e) {
e.preventDefault();
}
});
本文标签: javascriptHTML5 how do I disable all links after any one of them are clickedStack Overflow
版权声明:本文标题:javascript - HTML5: how do I disable all links after any one of them are clicked? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745408412a2657354.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论