rendered paste body<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><script type="text/javascript"> function img() { var imgs = document.getElementsByTagName('img'); var counter = 0; //for (counter=0; counter<img.length; counter++) // document.write(img[counter] + "<br>"); for(var i = 0; i < imgs.length; i++) { show(imgs[i].getAttribute('alt')); if(imgs[i].getAttribute('alt')=='hello') { show("yes"); //img = '<a href="' + img.src + '">' + img.src + } } //document.write("yes"); } function test() { if(document.getElementsByTagName("img").src=="sdf") { document.getElementsByTagName("img").style.display="none"; } } function show(txt) { document.getElementById("output").innerHTML += txt + "<br />"; }</script></head><body onload="img()"> <img src="Picture 1.png" alt="hello" id="ddd" style="display:block" onclick="test()" width="100" /> <div id="output"></div></body></html>