With jQuery, you can change dynamically the css class of a html element.

By example, if i want change the color of a button id= »
btnsubmit  » via a css class, by exemple from grey to purple when the button become activate.

First, i remove the disabled attribute :

$(‘#btnsubmit’).prop(« disabled », false);

After, you remove the old class affected to the button with the ancient color :

$(‘#btnsubmit’).removeClass(« buttonsubdisabled »);

Finally, you can add dynamically the new class containing the new background color for the button :

$(‘#btnsubmit’).addClass(« buttonsub »);

You may be interested with :

This article contain affiliate links.

Laisser un commentaire