Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi..
how to make hyperling unclickable once it click using jquery/javascript.
dont want to use this:
C++
document.getElementById('events').disabled = true;

and this
C++
$('#events').removeAttr('href');
Posted
Updated 14-Dec-10 2:48am
v3

You can also do it this way:

HTML
<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>



Cheers,


Manfred
 
Share this answer
 
v4
Comments
fjdiewornncalwe 13-Dec-10 15:30pm    
Not sure why you got a 3 on this... I like this solution if the ones the OP suggested can't be used.
niravsahayata 14-Dec-10 0:22am    
thanks for this ..
but its not working as i am calling jquery on hyperlink click event, so each time i click the link
it perform some operation.
This will allow one click to perform an action, and then subsequent clicks will do nothing.
HTML
<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>

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.
 
Share this answer
 
Here is an alternate version that uses a variable rather than swapping the onclick handler:
HTML
<html>
<head><title>Say Hello</title></head>
<body>
	<script type="text/javascript">
		var shouldSayHello = true;
		function sayHello(element) {
			if(shouldSayHello) {
				shouldSayHello = false;
				alert("Hello!");
			}
			return false;
		}
	</script>
	<a href="#" onclick="sayHello(this);">Say Hello</a>
</body>
</html>
 
Share this answer
 
Looks like you missed this tip: Disable all 'links' on the page via Javascript[^]
 
Share this answer
 
Comments
niravsahayata 14-Dec-10 0:28am    
thanks for this
but objLinks[i].disabled = xHow; not working in ff.
i am also calling a jquery on hyperling click evnt.
Could you simply make some blue text with a blue underline?
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900