2015-01-19 1 views
0

를 작동하는 버튼을 만들 JQuery와으로 .Append() 메소드에 버튼 클래스 또는 ID를 추가 할 수 없습니다, 당신에 의해 행을 삭제할 수 있습니다는 삭제 기능을 실행하는 대신

$("#app-table").append("<tr><td>"+sernumb+"</td><td>"+person.name1+"</td><td>"+parseInt(person.rollno)+"</td><td>"+person.address+"</td><td><button id='sideb"+r_index+"' type='button' onclick='delete_row(this);'>Delete</button></td></tr>");  // delete button to be added 
    }); 
    $("#btn2del").click(function() { 
     $("#app-table tr:last").remove(); 
    }); 
    $("#row1del").click(function() { 
     $("#app-table tr:nth-child(1)").remove(); // deleting everything but the mentioned item in not 
    }); 
    $("#delete-c").click(function(){ 
     alert("Its Working"); 
    }); 

}); 
function delete_row(ele){ 
     var index=$(this).parent().parent().index(); 
     $("#app-table tr").eq(index).remove(); // deleting current row   
} 
+0

답을 찾았습니까? – Sachin

답변

0

버튼 클래스를 실행하는 습관 :

function delete_row(ele){ 
    var parent_tr=$(this).closest('tr').remove();// deleting current row   
}