You can modify the code as follows to achieve the desired behavior:

function qq_single_add_itemX(item_id, item_qty, data_count) {
  var validate = '';
  var qq_order_items = [];

  $('.qcart_item').each(function() {
    var qcart_item = $(this).find(item_id).closest('.qcart_item');
    // Rest of your code using qcart_item instead of $(this)

  });
}

In the modified code, '$(this)' inside the 'each()' function is replaced with '$(this).find(item_id).closest('.qcart_item')'. This will select the element with 'item_id' within the current '.qcart_item' element, and then find the closest ancestor with the class '.qcart_item'. The 'qcart_item' variable can be used in the remaining code within the 'each()' function.

jQuery: Selecting Closest '.qcart_item' Element in Each Function

原文地址: https://www.cveoy.top/t/topic/qc70 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录