How to select an event by class in the prototype

in jQuery. I am raising an event by class. how do you do the same in Prototype.

$(".button").click(function() {
  var element = $(this);
  var Id = element.attr("id");
});
+3
source share
2 answers
$$('.button').observe('click', respondToClick);

function respondToClick(event) {
   var element = event.element();
   var Id = element.id;
}

http://www.prototypejs.org/api/event

+5
source
Event.observe($$('.button'), 'click', function(e) {
    // ...
});
+1
source

Source: https://habr.com/ru/post/1724969/


All Articles