Where The Streets Have No Name

element find function 본문

Developement/Web

element find function

highheat 2008. 11. 8. 19:09
function findParentTag(elem, sTag) {
    while(elem && elem.tagName.toUpperCase() !='BODY'){
        elem = elem.parentNode;
        if(elem.tagName.toUpperCase() == sTag.toUpperCase())return elem;
    }
}

function findTagByName(elem, tagName, name) {
    var tags = elem.getElementsByTagName(tagName.toUpperCase());
    for (var idx=0; idx<tags.length; idx++) {
       if (tags[idx].name == name) return tags[idx];
    }
    return null;
}

function findParentRow(elem){
    while(elem && elem.tagName.toUpperCase() !='BODY'){
        elem = elem.parentNode;
        if(elem.tagName.toUpperCase() == 'TR' && elem.id.toLowerCase() == 'row')
            return elem;
    }
}

function findInRow(elem, tagName, name){
    var row = findParentRow(elem);
    return findTagByName(row, tagName, name);
}