Jquery has a great language construct that looks like this:
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
As you might guess this, once the document has loaded, binds a custom function to the onClick event of all a tags.
The question is, how can I achieve this same kind of behavior in Prototype?
Prototype 1.6 provides the dom:loaded
event on document:
document.observe("dom:loaded", function() {
$$('a').each(function(elem) {
elem.observe("click", function() { alert("Hello World"); });
});
});