Is there a simple way to remove a class from an element when I don't know the exact class name (only a prefix)?
At first this might sound strange so I give an example to clarify: a Bootstrap button may have btn-primary
xor btn-success
xor btn-danger
xor ... applied. I want to remove this class (whichever it is) and apply a new one.
Currently I have:
let btnClasses = [ 'btn-primary', 'btn-success', ... ];
$.each(btnClasses, function(i, x) {
$(myElem).removeClass(x);
});
I'd love to have something alike:
$(myElem).removeClass('btn-*');
Is there a built-in way to do so?