javascript - Remove all classes that begin with a certain string -
i have div id="a"
may have number of classes attached it, several groups. each group has specific prefix. in javascript, don't know class group on div. want able clear classes given prefix , add new one. if want remove of classes begin "bg", how do that? this, works:
$("#a").removeclass("bg*");
with jquery, actual dom element @ index zero, should work
$('#a')[0].classname = $('#a')[0].classname.replace(/\bbg.*?\b/g, '');
Comments
Post a Comment