0

I don't know why buy javascript say my div is null.

this the javascript code:

    var box = document.getElementById("box");
box.style.height= box.innerText;

and this is the HTML:

 <html>
  <head>
 <link rel="stylesheet" type="text/css" href="classStyle.css">
   </head>
     </head>
     <body onmousemove="search()">

     <script src="java.js"></script>

     <center>
      <div id="header">Fantasy class</div>  
       <div id="box">50%</div>
     <div type=buttom> יצירת ליגה</div>
     </center>
     </body>
      </html>

1 Answers1

1

Your script tag appears before the div id="box". Therefore, it is run before that div is created, and returns null. To fix this, try moving the script tag under the div.