Reputation: 16590
i append a text input into form by using javascript, after i removed it by removeNode, it disappear, document.forms["form"].length = 0, but i can still get it's obj by using document.forms["form"]["inputname"] (not return null)
why?
Upvotes: 1
Views: 119
Reputation: 1521
anyway, you have to use document.getElementById() to correctly operate with elements tree. Constructions like document.forms[] is very old IE-oriented. But supported by some browsers for backward compatibility.
Upvotes: 0
Reputation: 187030
I think you are having trouble with firefox. In IE your code seems to work without any problem.
For removeNode to work in both IE and FF you can write like this
var objectToRemove = document.getElementByID ( "your object to remove" );
var parentNode = objectToRemove .parentNode;
parentNode.removeChild ( objectToRemove );
Hope this helps
Upvotes: 1