I have a bunch of input boxes and a button at the last input box to add more input boxes which. I have a problem removing the button when the add button is clicked.
I am getting this error on trying to removing a child element.
Error: uncaught exception: [Exception… “Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.removeChild]” nsresult: “0x80004003 (NS_ERROR_INVALID_POINTER)” location: “JS frame
When you are first creating the
addBtnelement, you are only setting thenameproperty.You need to set the
idproperty as well.So, in
createCreditBalanceInputs, change the code to include this line (addBtn.id = "addBtn";):Then, you don’t need to create the button every time. You can just keep appending it and the DOM hooks will automatically remove it from its previous position. You can change
addCreditBalanceto look more like this:and remove the earlier line where you invoked the
removeChildcall.