Array.length problem in JavaScript – Education Career Blog

I’ve written this sample code to print the length of x. But for some reason, I am not getting anything! Help!

<html>
<head>
<script type = "text/javascript">
function myF()
{
   var x = 1,2,3,4;
   var y = document.getElementById("thing");
   y.innerHtml = x.length;
}
</script>
</head>

<body onload = "myF();" >

<div id = "thing" >
PRINT TEST
</div>

</body>
</html>

,

The property name is innerHTML rather than innerHtml.

Leave a Comment