Something like this should work:
$('#theelement').mouseover(function(e) {
var classes = ['class1', 'class2', 'class3', 'class10'],
$this = $(this),
current = $this.attr('class').split(' ');
for (var i = 0; i < current.length; i++) {
lindx = $.inArray(current[i], classes);
if (lindx != -1) {
classname = current[i];
next = lindx + 1 >= classes.length ? classes[0] : classes[lindx + 1];
$this.toggleClass(classname + ' ' + next);
break;
}
}
});
http://jsfiddle.net/szh7K/
Ive done it this way instead of using a counter so that there is no need for an external variable. PRobably a better implementation would be to use a counter instead of searching the array everytime but use $.data to store that counter index on the element itself.
$('#theelement').mouseover(function(e) {
var classes = ['class1', 'class2', 'class3', 'class10'],
$this = $(this),
cur = $this.data('currentIndex')||0, // if there is no value then we start from scratch
next = cur+1 >= classes.length ? 0 : cur+1; // if we are at the end we start over
$this.toggleClass(classes[cur] + ' ' + classes[next]); // toggle the classes
$this.data('currentIndex', next); // assign the incremented index as current
});
http://jsfiddle.net/jkPps/1/