本文介绍了使超链接不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..
一旦使用jquery/javascript,如何使Hyperling不可点击.
不想使用此:
Hi..
how to make hyperling unclickable once it click using jquery/javascript.
dont want to use this:
document.getElementById('events').disabled = true;
还有这个
and this
$('#events').removeAttr('href');
推荐答案
<html>
<body>
<script type="javascript">
function blockEvent()
{
' You can do some logic here to determine when blocking should occur
return false;
}
</script>
<a id="event" href="http://www.google.de" onclick="return blockEvent();">Google</a>
</body>
</html>
干杯,
曼弗雷德(Manfred)
Cheers,
Manfred
<html>
<head><title>Say Hello</title></head>
<body>
<script type="text/javascript">
function returnFalse() {
return false;
}
function sayHello(element) {
alert("Hello!");
element.onclick = returnFalse;
return false;
}
</script>
<a href="#" onclick="sayHello(this);">Say Hello</a>
</body>
</html>
如果您想动态地执行此操作(即,无需对最初调用的onclick处理程序进行硬编码),则必须稍有不同.
If you want to do this dynamically (i.e., without hard coding the onclick handler that initially gets called), then you''d have to do it slightly differently.
这篇关于使超链接不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!