R
R
roovwhite2018-10-03 22:27:37
Yandex maps
roovwhite, 2018-10-03 22:27:37

How to add a class to the label that the cursor is hovering over?

The problem is the following. There are several custom labels on the map, the code below, when hovering over any label, hangs a class on all labels at once.

myPlacemark.events
            .add('mouseenter', function () {
                $('.points').addClass('interested');
            });

How can I implement adding a class only to the label that the cursor is hovering over?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
roovwhite, 2018-10-04
@roovwhite

I found a solution, maybe it will be useful for someone.

myPlacemark.events
            .add('mouseenter', function (event) {
                let _this = event.get('target').getOverlaySync().getLayoutSync().getElement(); // Родительский контейнер html.
                let pinner = _this.children[0]; // Вложенный элемент.

                $(pinner).addClass('interested');
            })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question