title: trouble with a javascript Cannot read property 'value' of
body: <p>I've done a function but I do not understand why, a part of it does not work.</p>
  
  <p>Actualy I use the methode using className and Id.</p>
  
  <p>Here is the part of the code:</p>
  
  <pre><code> var items = new Array();
   var itemCount = document.getElementsByClassName("items");
  
   for(var i = 0; i &lt; itemCount.length; i++)
   {
       items[i] = document.getElementById("p"+(i+1)).value;
   }
  
   return items;
   }
  </code></pre>
  
  <p>And in jsfiddle the html part that show that this Id exist.</p>
  
  <p>So it should not return to me this errors:</p>
  
  <p>Uncaught TypeError: Cannot read property 'value' of null fiddle.jshell.net:402</p>
  
  <p>the concerned line is the following:</p>
  
  <p>items[i] = document.getElementById("p"+(i+1)).value;</p>