You can use the document.getElementsByClassName
method, but it isn't standard yet (it will be part of HTML5), you can be completely sure that it will not work on any IE version, some modern browsers provide a native implementation, but if it isn't available, a loop checking for the specific class you look for can be done.
I personally use the following function, inspired by the Dustin Diaz implementation:
function getElementsByClassName(node,classname) {
if (node.getElementsByClassName) { // use native implementation if available
return node.getElementsByClassName(classname);
} else {
return (function getElementsByClass(searchClass,node) {
if ( node == null )
node = document;
var classElements = [],
els = node.getElementsByTagName("*"),
elsLen = els.length,
pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"), i, j;
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
})(classname, node);
}
}
Then you can use it like this:
window.onload = function () {
var returnFalse = function () { return false; },
els = getElementsByClassName(document, 'yourClassName'),
n = els.length;
while (n--) {
els[n].onselectstart = returnFalse;
}
};