Forum Moderators: open
<form class="submit-answers>
<div>
...
</div>
</form>
Seems like that would solve the problem.
Adding an id will not mess up the class unless there is a defined css id/class of the same name... just make sure it is a unique name and it should be fine.
<form class="submit-answers" id="submit_answers_form">
<div>
...
</div>
</form>
Just make sure the ID doesn't have any '-' in them as that can get confused as an operator by code.
[edited by: Demaestro at 9:01 pm (utc) on Dec. 18, 2007]
/*
Written by Jonathan Snook, [snook.ca...]
Add-ons by Robert Nyman, [robertnyman.com...]
*/
function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^¦\\s)" + strClassName + "(\\s¦$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
Some ways to call it.....
To get all a elements in the document with a “info-links” class.
getElementsByClassName(document, "a", "info-links");
To get all div elements within the element named “container”, with a “col” class.
getElementsByClassName(document.getElementById("container"), "div", "col");
To get all elements within in the document with a “click-me” class.
getElementsByClassName(document, "*", "click-me");