如何禁用jquery ui按钮(<a> tag turn to button)

时间:2015-09-29 11:01:03

标签: jquery jquery-ui

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?

1 个答案:

答案 0 :(得分:1)

是的,这仅适用于<button>元素。

请在此处查看我的jsfiddle:http://jsfiddle.net/xBB5x/9544/

您必须删除a的onclick才能停止工作:

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

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