Im new to javascript and i cant figure out what im doing wrong here.
I made javascript where you can put products to a table. It makes a row with product, price and delete.
This is working but, my delete button or my delete function isnt working.
Also, setting a "type" attribute on a td element doesn't do anything. Td elements don't have a type attribute. The onclick will work anyway, as it works on any element.
Finally, at the end of your posts here there's an Edit Post button. You should also use [ code] tags for better looking code.
I chanced the button code as you said. Its now removing only the delete button, but not the product and price.
Do I need to add something to this elements to?
You're still not adding any of the td elements to the tr element. It should look something like this:
Code:
var tr = document.createElement("tr");
document.getElementById("product-list").appendChild(tr);
tr.appendChild(productList);
tr.appendChild(productData);
tr.appendChild(prijsData);
tr.appendChild(verwijder);
Your deleteRow function looks correct. event.currentTarget should be the td, which means event.currentTarget.parentElement should be a tr element. You can always alert an element's tagName attribute to see what kind of tag it is.
(And it's weird, the Edit button seems to be gone for me too! It was just there some days ago.. :S )
Bookmarks