Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm building a react web app using Bootstrap and I have a delete button (also with the Bootstrap template) and I want to delete a Bootstrap object with that delete button.

How do I achieve this, and what is the quickest way?

Thank you!

What I have tried:

I've tried to code it and searched it up, but I have no results.
Posted
Updated 11-Aug-20 21:56pm

1 solution

It's about deleting some HTML tags as required. Thus, you need to define an event and then wire that to find the element that needs to be removed (using JavaScript/jQuery) and then remove it.

Like removing a table row using a delete button:
function productDelete(ctl) {
  $(ctl).parents("tr").remove();
}

An example on similar lines here: Add, Edit and Delete Data in an HTML Table Using JavaScript and jQuery[^]
 
Share this answer
 
Comments
h311o 12-Aug-20 4:36am    
Then how do I implement this in React? When I paste it in my function for deleting the object it gives me errors.
Sandeep Mewara 12-Aug-20 4:46am    
In React too, you would be having HTML defined probably in components. You need to find the element and remove it using Javascript.
h311o 12-Aug-20 4:52am    
Okay, I will try to work it out now. Thank you Sandeep!
Sandeep Mewara 12-Aug-20 4:59am    
Welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900