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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -