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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -