我有以下按钮:
<a type="button" class="btn btn-primary disabledButton">Download</a>
我想使用.prop
JQuery的属性禁用它。像这样:
$('.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] 删除。
我来说两句