disable href after 1 click on html?
This is simpler approach using jQuery that prevents links double clicking: no onclick
attributes, id
isn't required, no href
removing.
$("a").click(function (event) {
if ($(this).hasClass("disabled")) {
event.preventDefault();
}
$(this).addClass("disabled");
});
Tip: you can use any selector (like button
, input[type='submit']
, etc.) and it will work.
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>
just try this....
a:visited {
color:green;
pointer-events: none;
cursor: default;
}