javascript - TypeError: property 1 is non-configurable and can't be deleted -
for below page,
<body> <form name="testform" action="webtunings.php" method="get"> <input type="text" name="city"> <input type="submit"> </form> <form action="test.php" method="post" id="id1"> <input type="radio" name="iscorrect" value="yes" > <input type="radio" name="iscorrect" value="no"> </form> </body>
below code,
> var obj = document.getelementsbytagname('form') undefined > obj htmlcollection [ <form>, <form#id1> ] > array.prototype.pop.call(obj);
gives error: typeerror: property 1 non-configurable , can't deleted
below code deletes form
element,
> var obj = document.getelementbyid("id1") undefined > obj.parentnode.removechild(obj)
using array.prototype.pop
, why browser says non-configurable property of obj
unlike second approach?
the html collection contains live list of form elements in dom.
if remove form dom list automatically update.
you can't remove element directly list. designed forbid that.
Comments
Post a Comment