3
I need to remove all classes starting with btn-*
.
My script:
if (document.getElementById('contato_'+id).classList.contains('btn-danger') ){
document.getElementById('contato_'+id).classList.remove('btn-danger');
document.getElementById('contato_'+id).classList.add('btn-success');
}
The problem is that it only excludes a specific class.
You could select the classes by regular expression, rename them all to the same name and then remove.
– Luiz Fernando da Silva
You want to remove in a specific element or in all?
– Sergio
In my case this code is part of a function from which you take a specific element. Then I want to remove the class from the same element.
– André Cabral