首页 > 解决方案 > JQuery ajax返回没有类的新html

问题描述

我有这样的 ajax 过滤项目的代码

type: 'POST',
    dataType: 'HTML',
    url: somefile.ajax_url, 
    data: data_vals + '&action=content&arg=' + arg,
    success: function (response) {
    jQuery('#content').html(response);

它返回新的 html 代码,但删除了使用 jQuery 添加的类:

Query(document).on('click','.filter-toggle', function () {
        jQuery(this).toggleClass("active").next().slideToggle();
    });

过滤器 html 代码在返回的新 html 代码中,因此在返回新 html 过滤器后没有活动类并且它被关闭。当它返回新的 html 时,如何防止剥离类“活动”?

标签: phpjqueryhtmlajaxwordpress

解决方案


推荐阅读