views:

343

answers:

1

Is there any easy way to remove all classes matching, for example,

color-*

so if I have an element:

<div id="hello" class="color-red color-brown foo bar"></div>

after removing, it would be

<div id="hello" class="foo bar"></div>

Thanks!

+5  A: 
$('div').attr('class',
           function(i, c){
              return c.replace(/\bcolor-\S+/g, '');
           });
Kobi