Remove table row after clicking table row delete button

后端 未结 4 746
刺人心
刺人心 2020-12-01 08:00

Solution can use jQuery or be plain JavaScript.

I want to remove a table row after user has clicked the corresponding button contained in the table row cell so for e

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 08:52

    You can use jQuery click instead of using onclick attribute, Try the following:

    $('table').on('click', 'input[type="button"]', function(e){
       $(this).closest('tr').remove()
    })
    

    Demo

提交回复
热议问题