PinoyTech.org

CodeIgniter, Kohana, Mootools, jQuery and CSS

Prototype shortcut for Observe

Posted by teejay on February 11, 2011

This is some shortcut of Prototype JS on observing events

$$('#related_pics img').invoke('observe', 'click', function(){
    alert(this.src);
});

$$('#related_pics img').each(function(element){
    Event.observe(element, 'click', function(){
        alert(this.src);
    });
});

Categories: Web Development

Tags: javascript, prototypejs

No Comments

Comments are not allowed