次の html 構造があります (これは単なる概要であり、すべての div にはコンテンツがあり、適切に閉じられています)。各 div.views-row には、views-field-title、views-field-body、および views-field-afbeeldingen が含まれています
<div class="view view-toepassingen view-id-toepassingen view-display-id-page view-dom-id-5a6ac8323a7566e5f11218e7b6c49c5c">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first">
<div class="views-field views-field-title">
<div class="views-field views-field-body">
<div class="views-field views-field-field-afbeeldingen">
</div>
<div class="views-row views-row-2 views-row-even">
<div class="views-row views-row-3 views-row-odd">
<div class="views-row views-row-4 views-row-even">
<div class="views-row views-row-5 views-row-odd">
<div class="views-row views-row-6 views-row-even views-row-last">
</div>
私が達成しようとしているのは、divを次のように再配置することです:(タイトルと本文のdivを「afbeeldingen」div内に効果的に移動し、ビュー行ごとに移動します)
<div class="view view-toepassingen view-id-toepassingen view-display-id-page view-dom-id-5a6ac8323a7566e5f11218e7b6c49c5c">
<div class="view-content">
<div class="views-row views-row-1 views-row-odd views-row-first">
<div class="views-field views-field-field-afbeeldingen">
<div class="views-field views-field-title">
<div class="views-field views-field-body">
</div>
</div>
<div class="views-row views-row-2 views-row-even">
<div class="views-row views-row-3 views-row-odd">
<div class="views-row views-row-4 views-row-even">
<div class="views-row views-row-5 views-row-odd">
<div class="views-row views-row-6 views-row-even views-row-last">
</div>
これは、誤動作している私のjqueryコードです。6 つのビュー行の div すべてをループしようとしています。
var i = 1;
$('.view-toepassingen > .view-content').children('div').each(function () {
$('.view-toepassingen > .view-content > .views-field-field-afbeeldingen').prepend($('.view-toepassingen > .view-content > .views-row-'+i +' .views-field-title'));
$('.view-toepassingen > .view-content > .views-field-field-afbeeldingen').prepend($('.view-toepassingen > .view-content > .views-row-'+i +' .views-field-body'));
i++;
});