2010-11-28 53 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; 
    } 
...