Using onclick function in all img tags not a good method as you would have a nightmare if you made a small change. Add a class, and then using jquery you can get this to work. See the following.
Using the class attribute:
<img src="http://4.bp.blogspot.com/-uyvTMZ3dFPs/UKHsc_ZbysI/AAAAAAAACvo/QdVAlVBbUxE/s320/1hello.jpg" class="image"/><br> <img src="http://hearstcommerce.ca/customcontent/members/premium/sample.jpg" class="image" /><br> <img src="http://www.find-a-job-online.org/images/picture.gif" class="image"/>
Script:
$(".image").click(function(){ var src = $(this).attr('src'); alert("SRC = " + src); });
Fiddle: http://jsfiddle.net/yL5cf/6/
source share