how to get image in javascript code example

Example 1: js get image src

var youtubeimgsrc = document.getElementById("youtubeimg").src;

Example 2: show image javascript

JS:
function setImageVisible(id, visible) {
    var img = document.getElementById(id);
    img.style.visibility = (visible ? 'visible' : 'hidden');
}

HTML:
<img id="myImageId" src="yourImage.png">
Then, your links would be:
<a href="javascript:setImageVisible('myImageId', true)">show image</a>
<a href="javascript:setImageVisible('myImageId', false)">hide image</a>

CSS:
#theImage { visibility: hidden; }