使超链接不可点击 [英] make hyperlink unclickable

查看:94
本文介绍了使超链接不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
一旦使用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');

推荐答案

(' #events').removeAttr(' span> href');
('#events').removeAttr('href');


您也可以这样操作:

You can also do it this way:

<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


这将允许单击一次执行某项操作,然后随后的单击将无济于事.
This will allow one click to perform an action, and then subsequent clicks will do nothing.
<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.


这篇关于使超链接不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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