Skip to content
Advertisement

Want to remove previously appended table

When I Click on submit button after clicking on the links it appends perfectly but when I hit the button again it doesn’t remove previously appended table. I want to clear the previously created table when user clicks on the cross button and then print the table again or else overwrite the table but instead it is not removing the table and prints a new one.Image Part OneImage Part TwoImage Part ThreeImage Part Four

JavaScript
JavaScript
JavaScript

Advertisement

Answer

  • Update your remove function as function remove(el) { el.closest('table').remove(); }.
  • Update parameter in html as "</td><td onclick='remove(this)'>&times;</td></tr>".
  • And add orders_list = []; in the end of loop function.

Try it below.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement