2017-03-26 1 views
1

마지막 섹션 만 복제하도록 jquery 코드를 설정하는 방법은 무엇입니까?jquery - 마지막 섹션 복제 방법

그래서 다음 클릭 나에게 줄 것이다 : <section id="unit4">cc</section>

JQUERY

$("#addUnit").click(function() { 
    // Clone the last SECTION 
    var new_section = $('section').XXXXXXXXXX.clone().fadeIn("slow"); 
    new_section.attr("id", "unit"+unitCount); 


    $('section').last().after(new_section); 
    unitCount = unitCount+1; 
}); 

HTML

<section id="unit1">aa</section> 
<section id="unit2">bb</section> 
<section id="unit3">cc</section> 
<p> 
    <button type="button" id="addUnit" name="btnAdd" class="btn btn-info">add section</button> 
</p> 
+0

이미'.last을 사용 해야할지()'$ ('섹션') 답을'이잖아. 마지막(). 복제를 () .... – Satpal

답변

0

을 당신이 할 수있는 최신 광고를 복제해야합니다

var new_section = $('#unit'+unitCount).clone().fadeIn("slow"); 

DED 섹션.에

퇴색하거나 심지어는 마지막 선택을 시도

var new_section = $("section:last").clone().fadeIn("slow");