function getElementsByClassName(searchClass, node, tag)
{
var classElements = new Array();
if (node == null)
{
node = document;
}
if (tag == null)
{
tag = '*';
}
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
for (var i = 0, j = 0; i < elsLen; i++)
{
if (pattern.test(els[i].className))
{
classElements[j] = els[i];
j++;
}
}
return classElements;
}
function findPosition( oElement ) {
if( typeof( oElement.offsetParent ) != 'undefined' ) {
for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
}
return [ posX, posY ];
} else {
return [ oElement.x, oElement.y ];
}
}
No comments:
Post a Comment