Remove table row after clicking table row delete button

后端 未结 4 745
刺人心
刺人心 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:46

    Using pure Javascript:

    Don't need to pass this to the SomeDeleteRowFunction():

    
    

    The onclick function:

    function SomeDeleteRowFunction() {
          // event.target will be the input element.
          var td = event.target.parentNode; 
          var tr = td.parentNode; // the row to be removed
          tr.parentNode.removeChild(tr);
    }
    

提交回复
热议问题