1

У меня несколько элементов с таким классом, но при наведении срабатывает сразу на всех элементах с этим классом, как сделать чтобы событие срабатывало только для того элемента, на который наведен курсор мыши?

jQuery(document).ready(function ($) {
    $(".has__child").mouseenter(function (event) {
        $(".has__parent").css({"display":"flex"});
    }).mouseleave(function (event) {
        $(".has__parent").css({"display":"none"});
    });

    $(".has__parent").mouseleave(function (event) {
        $(this).css({"display":"none"});
    }).mouseenter(function (event) {
        $(".has__parent").css({"display":"flex"});
    });
});

1 ответ 1

1
$(".has__child").mouseenter(function (event) {
    $(this).find(".has__parent").css({"display":"flex"});
}).mouseleave(function (event) {
    $(this).find(".has__parent").css({"display":"none"});
});

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.