Skip to content Skip to sidebar Skip to footer

How To Get The Src Of A Clicked Image With Prototype

I am struggling to get the image src of a image when its clicked. I just need the jQuery(this).attr('src') but in prototype, this.readAttribute doesn't work. I get: “this.readAtt

Solution 1:

Try this:

updateImage: function (){

var src = $(this).readAttribute('src');

...
}

Solution 2:

Thanks wajiw I fixed it by var that = this, so I could use it later and getting rid of .bind(this)

Solution 3:

You're binding an event, so the click-handler should be:

...
updateImage: function(event)
   {
      var img = Event.findElement(event, 'IMG');
      var src = img.src;
   }
...

Post a Comment for "How To Get The Src Of A Clicked Image With Prototype"