Показать сообщение отдельно
  #2 (permalink)  
Старый 07.04.2023, 14:32
Профессор
Отправить личное сообщение для Nexus Посмотреть профиль Найти все сообщения от Nexus
 
Регистрация: 04.12.2012
Сообщений: 3,736

Your script stops working after content updating 'cause «updating» replaces old content with your listeners with new one without them.
You can solve that problem by delegating the listeners to the closest parent which won't be changed by ajax or you can just listen document events.

Example of code:
$(function () {
    $(document).on('mouseenter', '.firm_card_container > :not(.r_gl_3)', function () {
        $(this).css('background-color', '#FFE9CC');
    }).on('mouseleave', '.firm_card_container > :not(.r_gl_3)', function () {
        $(this).css('background-color', '#EFF9F8');
    });
});
Ответить с цитированием