Prototype - click event by element class name
Can be also be done with a single-liner, as someone already suggested in a comment:
$$('.btn').invoke('observe', 'click', respond);
Unlike jQuery, handing selectors with multiple results in Prototype works a little differently. You need to handle each selected result separately using .each()
.
$$('.btn').each(function(element) {
element.observe('click', respond);
})
This is one of the reasons I moved over to jQuery. The other reason: knowing jQuery is marketable and knowing Prototype is not.