VANHIEP.NET - Làm web giá rẻ - Thiết Kế Website - Thiết Kế Ứng Dụng Mobile

Khắc phục lỗi hàm hover jquery không hoạt động sau khi apend html

code ban đầu

$('.product-item').hover(function () {

  $('.product-item').removeClass('product-item-active')

  $(this).addClass('product-item-active')

})

Thay bằng

 

$(document).on('mouseover', 'div.product-item', function (e) {

  $('.product-item').removeClass('product-item-active')

  $(this).addClass('product-item-active')

});