14-May-05 (Created: 14-May-05) | More in 'CS-JavaScript'

Exercising Children of an html node in javascript

//************************************************************
//Returns a string value 
//of the url for the image of an anchor object
//************************************************************
function getImageSrc(saveAnchor)
{
   //alert("Working with an anchor:" + saveAnchor.href);
   imgElement = saveAnchor.children[0];
   if (imgElement == null)
   {
      //alert("Warning: this saveanchor does not have an image element");
      return null;
   }
   //alert("An image anchor found");
   //alert("The source of the image is: " + imgElement.src);
   return imgElement.src;
}