0

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 ?

2 Answers2

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.

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