div라는 'div.cloneFrame'이 있는데 jquery.clone을 사용하여이를 복제하고 있습니다. 그것을 잘 작동합니다 그리고 난이 기능을 사용하여, 내가 필요로하는 모든 복제 :Jquery 콜론 자식 카운트 문제 (n 번째 자식)
이var needToClone = 4;
var totalImgs = 0;
for(i=0;i<needToClone;i++){
$('div.cloneFrame').clone()
.removeClass('cloneFrame')
.appendTo('.frame-group').each(function(){
var imgSrcLength = $(this).find('img');
for(j=0;j<imgSrcLength.length;j++){
totalImgs++;
$(imgSrcLength[j]).attr('src','imgs/outfits/'+totalImgs+'.jpg');
}
})
}
$('div.cloneFrame').remove();
나중에 내가 그것을 위해 내가 n 번째 자식 기능
$('div.myframe:nth-child('+1+')').addClass('incoming').next().addClass('outgoing');
그러나 작동하지를 사용하고, 복제 된 DIV를 선택해야합니다. 만약 내가 이것을 사용한다면 :
$('div.myframe:nth-child('+3+')').addClass('incoming').next().addClass('outgoing');
그것은 잘 작동하고 있습니다. n 번째 자녀에게 2 자리 숫자를 건너 뛸 필요가있는 이유는 무엇입니까? 내 편이 잘못 됐어?
내 HTML :
<div class="frame-group">
<div class="cloneFrame myframe">
<div id="orange-frame" class="product-frame">
<a class="purchase-btn" href="#">Purchase this item</a>
<img alt="women coat" src="imgs/yellow-coat.jpg">
</div>
<div id="yellow-frame" class="product-frame">
<a class="purchase-btn" href="#">Purchase this item</a>
<img alt="blue coat" src="imgs/coat-blue.jpg">
</div>
<div id="brown-frame" class="product-frame">
<a class="purchase-btn" href="#">Purchase this item</a>
<img alt="women shoe" src="imgs/women-shoe.jpg">
</div>
<div id="green-frame" class="product-frame">
<a class="purchase-btn" href="#">Purchase this item</a>
<img alt="women jean" src="imgs/jean.jpg">
</div>
</div>
<span class="outfit-no">outfit no.<span>01</span></span>
<a class="buy-outfit" href="#">Buy outfit</a>
</div>
방문 : http://jsbin.com/iquxaq/3 JQuery와 :nth-child() 선택에서