I want the href
to be disabled after 1 click, can it be done using javascript or jquery?
Please help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns ="http://www.w3.org 1999 xhtml" xml :lang="en">
<head>
<style>
a:link{
color:#1DAAA1;
}
a:visited{
color:green;
}
a:hover{
background: #ff0000;
color: #FFF;
}
</style>
</head>
<body>
<table width="500" align="center" border="5px solid">
<tr align="center" >
<td><a href="http://www.google.com.my/" onclick="return false"> Google </a></td>
<td><a href="http://www.yahoo.com/"> Yahoo </a></td>
<td><a href="http://www.bing.com/"> Bing </a></td>
<td><a href="http://en.wikipedia.org/wiki/Main_Page"> Wikipedia </a></td>
<td><a href="https://www.facebook.com/"> Facebook </a></td>
</tr>
</table>
</body>
</html>
Pure javascript solution:
<script>
function clickAndDisable(link) {
// disable subsequent clicks
link.onclick = function(event) {
event.preventDefault();
}
}
</script>
<a href="target.html" onclick="clickAndDisable(this);">Click here</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With