如何使用原型获取点击图像的src [英] How to get the src of a clicked image with prototype

查看:121
本文介绍了如何使用原型获取点击图像的src的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击图像时,我正在努力获取图像的图像src.我只需要jQuery(this).attr("src"),但是在原型中,this.readAttribute不起作用.我得到:"this.readAttribute不是函数"

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.readAttribute is not a function"

$$('.more-views > ul > li > img').invoke('observe', 'click',  this.updateImage.bind(this));

updateImage: function (){
 //var src = jQuery(this).attr("src").replace("thumbnail/66x66", "image");//changes src from thumbnail to large image
 Needs the above but in prototype.

 //jQuery('#image').attr("src", src);//updates large image
 this.imageEl.writeAttribute("src","http://www.timelapseme.com/images/logonew.png");

 val_scale = !this.showFull ? this.slider.value : 1;
       this.scale(val_scale);

},

推荐答案

您正在绑定事件,因此单击处理程序应为:

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

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

这篇关于如何使用原型获取点击图像的src的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆