首页 > 解决方案 > JQuery 在其他函数中使用每个函数

问题描述

我正在使用 AJAX 函数,结果我正在$('.class').each执行一些逻辑。

问题是调用$(this)以检索每个对象,是指 AJAX 函数而不是找到的元素。

如何引用each函数中的元素?

$.ajax({url: "myurl", success: function(result){

                $(".my_class").each((index, dom) => {

                    console.log(($(this)));   //this is the ajax funct, not the object i want

                });

         });

标签: javascriptjqueryajaxthiseach

解决方案


推荐阅读