編寫時不知為何

名單會一直把tr的標籤去掉

導致名單歪掉

 

後來參考

http://webdesign.kerthis.com/jquery/jquery_manipulation

改寫

<script>
$(document).ready(function(){
$(".EM").on("click",".addBtn",function(){
//$(".addBtn").on("click", function () {
var newdata = $(".data").first().clone();// 不知道為什麼要加clone才能運作 參考網頁http://webdesign.kerthis.com/jquery/jquery_manipulation
//var newdata = $("<p>newnewnew data</p>")
$(this).closest(".data").after(newdata);
});

$(".EM").on("click", ".removeBtn", function () {
$(this).closest(".data").remove();
});
});
</script>

 

即可正常操作

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JayeChen987 的頭像
    JayeChen987

    Jaye的碎碎念

    JayeChen987 發表在 痞客邦 留言(0) 人氣()