0

I use Jquery UI 1.9.2 to convert an <a> tag into a button.
But disabling newly created button only affect appearance(good) and mouse click still works(bad).
I'm using firefox 32.
Here is my snippet:

<a href="#" onclick="alert('hi');">click me if enabled</a>
<script>
    $('a').button({disabled:true});
</script>

Is this behavior related to nature of <a> tag and cannot be addressed by jquery UI tools and options?
How can i suppress onClick anyway?

Rzassar
  • 2,117
  • 1
  • 33
  • 55
  • instead of the onclick attribute use jQuery event handlers - http://jsfiddle.net/arunpjohny/h2085ycd/1/ – Arun P Johny Sep 29 '15 at 11:08
  • Perhaps, this link can help you. [http://stackoverflow.com/questions/19006299/jquery-disable-and-enable-an-anchor-tag-based-on-condition](http://stackoverflow.com/questions/19006299/jquery-disable-and-enable-an-anchor-tag-based-on-condition) – A J Sep 29 '15 at 11:09

1 Answers1

1

Yes, this only works for <button> elements.

See my jsfiddle here: http://jsfiddle.net/xBB5x/9544/

You have to remove the onclick for the a to stop working like:

$("a").attr('onclick', '')

http://jsfiddle.net/xBB5x/9545/

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62