1const element = document.querySelector(".class__name");
2
3element.addEventListener("click", () => {
4 console.log("clicked element");
5});
1// There are quite a few abstracted versions of the following
2$('element').on('event', function() {
3 // Do something
4});
5
6// Where 'event' is something such as 'click', 'hover' etc
7
8// They are abstracted as seen below
9$('element').click(function(){
10 // Do something
11});
12$('element').hover(function(){
13 // Do something
14});
15
16// etc...
1var ViewName = Backbone.View.extend({
2 initialize: function(){
3 this.$el.on("eventName", this.functionName, this)
4 },
5 functionName: function(){
6 //whatever
7 },
8 remove: function() {
9 this.$el.off("eventName", this.functionName);
10 Backbone.View.prototype.remove.apply(this, arguments);
11 }
12});
1var ViewName = Backbone.View.extend({
2 initialize: function(){
3 this.$el.on("eventName", this.functionName, this)
4 },
5 functionName: function(){
6 //whatever
7 }
8});