If you're using the class just as a flag to compare two elements, why not use something just for that purpose? You didn't say how you selected the two element to start with - so I'll assume you gave them each an "id" - which are always different or your page will be messed up.
E.g.:
<element1 myflag='something' id='e1'>
<element2 myflag='also-something' id='e2'>
Now you can use:
document.getElementById('e1').getAttribute('myflag') to retrieve the attributes for the elements: Just compare the strings!
This makes two assumptions, top paragragph, and if either is wrong you'll need to adapt (possibly making them true?). Don't forget: string comparisons are case sensitive unless you take that into account.