Bootstrap 4.1 provides a class named disabled
and aria-disabled="true"
attribute.
example"
<a href="#"
class="btn btn-primary btn-lg disabled"
tabindex="-1"
role="button" aria-disabled="true"
>
Primary link
</a>
So if you want to make it dynamically, and you don't want to care if it is button or ancor
than
in JS script you need something like that
let $btn=$('.myClass');
$btn.attr('disabled', true);
if ($btn[0].tagName == 'A'){
$btn.off();
$btn.addClass('disabled');
$btn.attr('aria-disabled', true);
}
But be carefull
The solution only works on links with classes btn btn-link
.
Sometimes bootstrap recommends using card-link
class, in this case solution will not work.