Disabling Anchor Tags Using jQuery


#1

Hi everyone!

I’m developing a web application in these days. I use an tag which is stylized with CSS as a button. I need to make it disabled once the user clicks on it, using jQuery. I tried setting up something like $(’#id’).attr(“disabled”, “disabled”); but that didn’t work. Does anyone know how to use jquery to disable an anchor tag?


#2

You could define a CSS class “disabled” as followed:

.disabled { pointer-events: none cursor: default }

Or hook into it using jQuery with the click element, and check for the existence of a specific class. and to “event.preventDefault()” or something, if it exists.