2010-11-28 29 views
0

我很努力地获取图像的图像src时,它的点击。我只需要jQuery(this).attr("src")但在原型中,this.readAttribute不起作用。我得到:“this.readAttribute是不是一个函数”如何用原型获得点击图像的src

$$('.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); 

}, 

回答

0

试试这个:

updateImage: function(){ 

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

... 
} 
0

感谢wajiw我通过VAR是=这个固定的,所以以后我可以用它和摆脱.bind(本)

0

你结合的情况下,这样的点击处理程序应该是:

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