I want to make a link which automatically disable after clicking on it. User can click on it for just onetime. Can anyone help me ?
Asked
Active
Viewed 42 times
2 Answers
0
You can try this How do I disable a href link in JavaScript? or remove the element on click.
Bit of a strange thing to want, but ok.

Leif Messinger LOAF
- 169
- 9
-
I can't understand......see I want a `````` means link which automatically muted after first clicking......just it with javascript...... – Sayandweep May 30 '21 at 09:07
0
Can just do:
<a id="go_somewhere">go somewhere</a>
$('#go_somewhere').on('click', () => $('#go_somewhere').attr('disabled', true))
if you want to see it in action on this stack overflow page— paste this in console and click the "Ask Question" button in the upper right hand side of this page:
$('.ws-nowrap.s-btn.s-btn__primary').on('click', () => $('.ws-nowrap.s-btn.s-btn__primary').attr('disabled', true));
$('.ws-nowrap.s-btn.s-btn__primary').removeAttr('href'); // to avoid the redirect

svey
- 115
- 1
- 7