i have number of images on my webpage.
<img id="a" src="1.jpg">
<br>
<img id="b" src="2.jpg">
I am trying to get "src" of clicked images by using below javascript.
var getImageName = function(){
document.onclick = function(){
var image = this.getAttribute("src");
alert(image);
}}
getImageName();
But its giving an error this.getAttribute is not function.
Any idea? Thanks in advance