Setting nested DOM element attributes
I needed to set some attributes for some anchors in an iframe. I wanted them to open in the parent frame. The problem was I only wanted certain ones that were inside of certain elements. I wrote this javascript loop to find the <a> elements inside of the div with the id of "re".
function getAnchorsInResults{
rootElem = document.getElementById("re");
resultAnchors = rootElem.getElementsByTagName("a");
for(var i = 0; i < resultAnchors.length; i++){
resultAnchors[i].setAttribute("target", "_top")
}
}
