0

在这种情况下,我不确定如何定位我想要的元素:

  var $div = $(".row-container").filter(function() {
        return $(this).data("i") == product_id;
        // where value == product id to find
      });

现在,within$div是一个具有'price-row'我想要的类的元素。$div.hasClass('price-row')只返回真或假值。

4

1 回答 1

3

.find如果它是子元素则使用:

var $div = $(".row-container").filter(function() {
    return $(this).data("i") == product_id; // where value == product id to find
}).find('.price-row');

如果您的意思是匹配元素将在该集合中,请将其包含在开始的条件中:

var $div = $(".row-container.price-row").filter(function() {
    return $(this).data("i") == product_id; // where value == product id to find
});
于 2012-07-02T00:07:55.290 回答