[RESOLVED]Demo error

demo error – null or undefined

<script type="text/javascript">
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
var adds = ["Lemon","Tangerine","Kiwi"];
function myFunction() {
    for (i=0; i<2;i++)

    document.getElementById("demo").innerHTML = fruits;

    <form id="form1" runat="server">
   <p>The unshift method adds new elements to the beginning of an array.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo" >Hello</p>

Your script executes as soon as the browser receives it, so it is accessing the "demo" node that doesn’t yet exist.  Move your script block to the bottom of the page, below the things it accesses.

Leave a Reply