以下職位是爲巨大幫助的是我想要做的事: Builing a cart with multiple items and the PayPal button in PHP使用js/jQuery從表單中刪除動態創建的子節點?
這部分工作很漂亮:
var inp1 = document.createElement("input");
inp1.setAttribute("type", "hidden");
inp1.setAttribute("id", "item_number_" + current_item);
inp1.setAttribute("name", "item_number_" + current_item);
inp1.setAttribute("value", current_item);
document.getElementById("paypal-form").appendChild(inp1);
但我變得有點憋屈如何刪除當一個項目需要...我尋找的東西,如:
document.getElementById('payPalForm').removeChild(inp1);
但很明顯我需要一種方法來指定/跟蹤這些動態創建的id ...或者是有我缺少一個更簡單的方法?
任何幫助,將不勝感激。