Get Elements By Class
We include our ‘core’ library, in the header
<script src="../Include/Core.js" type="text/javascript"></script>
The function ssGetElementsByClass() takes in a class name and returns all the elements with that class. It works a bit like document.getElementsByTagName(), but is more flexible.
function prepareAlerts()
{
var anchors = ssGetElementsByClass("alert");
for (var aCount=0; aCount != anchors.length; aCount++)
{
ssAddEvent(anchors[aCount], "click", showAlert, false);
}
}
It can additionally take in an element and a tag name as parameters, and if so will only return child elements and those which match the tag name
var objSideBar = document.getElementById("sidebar")
var anchors = ssGetElementsByClass("alert",objSideBar,"a");