複数の要素に同じデータ属性を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 + ',');
});
入力フィールドでそれらを移入するには、なぜデータ・プロダクト・コードの値は、データ - と同じです商品名?私はそれを解決することができませんでした、なぜなら、1要素は2つのデータ属性を含むことができないからですか?
あなたは完全なHTMLを示すことができる:ここで
は修正されたコードがありますか? – JiFus