I'm trying to append the title of each image of an array to each individual image who's height and width are greater than x
*Couldn't figure out how to format this correctly with the editor
var curHeight;
var curWidth;
var hr;
function imgHr(){
var allImages = document.images;
for (var i=0; allImages.length > i; i++) {
var imgSrc = allImages[i].src;
var newImg = new Image();
newImg.src = imgSrc;
curHeight = newImg.height;
curWidth = newImg.width;
if(curWidth>='80' && curHeight>='80'){
var imgGet=allImages[i];
var hrT=allImages[i].title;
var hr= document.createElement("hr");
hr.style.border-bottom="1px solid skyblue";
hr.innerHTML=hrT;
//appendChild isn't working
imgGet.appendChild(hr);
//but everthing else works: example
imgGet.style.border="1px solid red";
} else {
//maybe add something later
}
}
}
OK this solved my case
function insertafter(newChild, refChild){
refChild.parentNode.insertBefore(newChild,refChild.nextSibling);
}
title
) after the image. but this can't be achieved in javascript alone. *sorry the horizontal rule was meant to be a header element (h1). I confused my self by using the hr(for header) as the variable.But thanks again – Tj tarmon Jul 15 '11 at 08:30