How to get the src from image in jquery – Education Career Blog

i have 3 images with the same id=”UserImages” i wanted to know if i can click on them and get the scr in jquery?

,

First I’d switch them to classes (IDs must be unqiue):

<img class="UserImages" src="..." />

Then use a .class selector to find them, like this:

$("img.UserImages").click(function() {
  alert(this.src);
});

Leave a Comment