M
M
megamutex2017-04-10 15:14:43
JavaScript
megamutex, 2017-04-10 15:14:43

Javascript OOP?

Good afternoon! I'm trying to learn OOP javascript with real examples and ran into a problem. There is this code:

function Widget(containerSelector) {
        this.$container = $(containerSelector);
        this.$widgetIco = this.$container.find('.js-box-ico');
        this.bindEvents();
    }
 Widget.prototype.bindEvents = function() {
        this.$widgetIco
            .on('mouseenter', this.addCell.bind(this))
            .on('mouseleave', this.removeCell.bind(this));
    };
Widget.prototype.addCell = function() {
// Добавить класс к наведенному элементу.
    };
 $(function() {
      new Widget('.box');
    });

I can't figure out how, for example, to add a class in Widget.prototype.addCell to the currently hovered .js-box-ico element?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question