you also could do this pretty easily on your own with out prototype
especially if the class is tag specific. Get a collection of tags
that the class is supposed to apply to say <td>. Then loop through
then checking there class value to see if it equals your 'myClass'.
You actually don't want to check if it's just equal. Since you could
have an element like <p class="myClass classtwo"> you would want to
check the indexOf('myClass') != -1 in that string. The problem with
this is that you will get false positives for things like <p
class="myClass2">. There are a couple options here, you could use
regular expressions (haven't really tested this but something like: /
([\w-]+\s+)*myClass(\s+[\w-]+)*/)or you could split on white space and
then iterate over the array which came back. I suspect that regular
expressions are going to be faster.
But if you're concerned with performance then checking to see if the
browser has its own getElementsByClassName method or a querySelector
that it makes public to the JS then you should use those and only
create one for yourself if those are not available. Also smart to
search/keep up on which engines support or have plans to support which
methods.