I made a function in javascript that checks to see if the div element with the #stage id has any children, and if so, it should remove them when the function is called.
When I start the site, Firebug returns me an error that looks like this: TypeError: value is not an object.
This is my code: Declaring a variable step in javascript:
var stage = document.querySelector("#stage");
The part of the javascript function that gives the error:
if (stage.hasChildNodes()) { for (var f1=0; f1<ROWS * COLUMNS; f1++) { stage.removeChild(stage.firstChild); } }
HTML code:
<body> <div id="stage"> </div> <script src="code.js"> </script> </body>
I want to remove the child nodes with the id "stage"
Please help me solve this problem. If you need more information about my problem, please ask. Thanks.
source share