내가 얻으려고하는 것 : 이미지 내용이 항상 텍스트 내용보다 앞에 있도록 모든 "행"-divs의 내용 순서를 변경하십시오..before() 여러 번 실행합니다.
HTML : 그것은 나중에 어떻게 보일지
<div class="row">
<div class="image">image content here</div>
<div class="text">text content here</div>
</div>
<div class="row">
<div class="text">text content here</div>
<div class="image">image content here</div>
</div>
:
<div class="row">
<div class="image">image content here</div>
<div class="text">text content here</div>
</div>
<div class="row">
<div class="image">image content here</div>
<div class="text">text content here</div>
</div>
내 jQuery를 :
$('.row').each(function() {
firstChild = $(this).find(':first-child');
if(firstChild.hasClass('text')) {
firstChild.before($(this).find('.image'));
}
else {
console.log("not text");
}
}
JQuery와는 조금 후, 이상한 주문의 이미지 DIV를 배치 코드에서 여러 개의 이미지가 사이트에 표시됩니다. :) 제발 도와주세요
바이올린이 도움이 될 것입니다. – turnt