Now it should obviously cater for all legal class usages, for example:
<div class="class1 class2 class3"> </div>
And I don't want to parse the document with regular expressions. That's simply too error prone. What I'm interested in is a Jaavascript solution that walks the DOM or uses something like jQuery to do that.