Hover not working after ajax function
I've got a filter on the website that uses ajax to pull through the specific post category. Before I choose a filter, the hover feature works fine and no issues.
However once the ajax function has run, the hover no longer works despite every reason it should.
I've googled and tried a number of ways to no success. Two of the options I've found so far which work fine before the ajax are;
- jQuery(document).on('mouseenter','.cont_panel__img', function(e){
- jQuery(this).toggleClass('active');
- jQuery(this).siblings().toggleClass('inactive');
- jQuery('.cont_panel__black').toggleClass('active');
- jQuery('.staff_overview').toggleClass('chosen_inactive');
- jQuery(this).siblings().find('.staff_overview').toggleClass('inactive');
- });
- jQuery(".cont_panel__img").on({
- mouseenter: function () {
- jQuery(this).addClass('active');
- jQuery(this).siblings().addClass('inactive');
- jQuery('.cont_panel__black').addClass('active');
- jQuery('.staff_overview').addClass('chosen_inactive');
- jQuery(this).siblings().find('.staff_overview').addClass('inactive');
- },
- mouseleave: function () {
- jQuery(this).removeClass('active');
- jQuery(this).siblings().removeClass('inactive');
- jQuery('.cont_panel__black').removeClass('active');
- jQuery('.staff_overview').removeClass('chosen_inactive');
- jQuery(this).siblings().find('.staff_overview').removeClass('inactive');
- }
- });
My ajax function is;
- jQuery(".work_cat li a.ajax").click(function (f) {
- var catValue = jQuery(this).attr("data-id");
- jQuery("a.ajax").removeClass("current");
- jQuery(this).addClass("current");
- jQuery.ajax({
- type: 'POST',
- url: post_ajax.ajax_url,
- data: {
- "action": "load-filter",
- cat: catValue
- },
- beforeSend: function() {
- jQuery(".height_support").animate({"height": "700px"});
- jQuery('.cont_panel').find( '.cont_panel__img' ).fadeOut( function(){ jQuery(this).remove(); });
- },
- success: function(response) {
- jQuery(".height_support").animate({"height": "0px"});
- jQuery("#category-post-content").html(response);
- // aosData();
- return false;
- }
- });
- f.preventDefault();
- });
Anyone came across this before and how to crack it? Cheers in advance