0
我把在多个元素(数据产品名称&数据产品代码),其目的是填充在一些输入字段从数据属性值2相同的数据属性。jQuery的显示值相同的属性
<strong class="displayed_product_name" data-product-name="All content" data-product-code="abc">All content</strong>
我抓住数据属性值,并将它们作为数组。
var arrProductCode = [];
$(this).closest('.each_content_item').find('[data-product-code]').each(function() {
arrProductCode.push($(this).text());
});
var arrProductName = [];
$(this).closest('.each_content_item').find('[data-product-name]').each(function() {
arrProductName.push($(this).text());
});
填充它们在元件和输入字段
$(arrProductName).each(function() {
$('.pop_edit_country').find('.pop_edit_product_list ul').append("<li>" + this + "</li>");
});
$(arrProductCode).each(function() {
$('.hidden_edit_country_product_list').val($('.hidden_edit_country_product_list').val() + arrProductCode + ',');
});
数据产品名称的值正确地抓住,但为什么的数据积代码的值是相同的DATA-产品名称?我无法解决它,是因为1个元素不能包含2个数据属性?
你能不能显示完整的HTML? – JiFus