JQuery 禁用按钮不起作用

凯文_b

我有以下按钮:

<a type="button" class="btn btn-primary disabledButton">Download</a>

我想使用.propJQuery属性禁用它像这样:

$('.disabledButton').prop('disabled', true);

但是,它不起作用,因为没有任何改变。有任何想法吗?

罗伯特·罗查

它不工作的原因是因为它是一个超链接并且它没有disabled属性。你唯一能做的就是preventDefault

https://dev.w3.org/html5/html-author/#the-a-element

<a type="button" class="btn btn-primary disabledButton">Download</a>

$('a.disabledButton').on('click', function(e) {
    e.preventDefault();
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章