Remove table row using jQuery

前端 未结 6 1658
别跟我提以往
别跟我提以往 2021-02-19 03:57

The following is my code

Script

$(document).ready(function(){
    $(\'#click\').click(function(){
        $(\'#table\').append(\'&a         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-19 04:36

    Find the last row with a selector and the delete that row like that:

    $('#table > tr:last').remove();
    

    This will delete the last row in the table. What if you want to delete the first?

    $('#table > tr:first').remove();
    

    That's it. There is codeschool online course for jQuery. You will find lot's of valuable stuff there including selectors and DOM manipulation. Here is a link: http://jqueryair.com/

提交回复
热议问题