function getImages(contentId) { var content = document.getElementById(contentId); // only one image, just return an item; or you can return an array if (content) return document.getElementsByTagName('img')[0]; }