title: how i can modify style of html element generated dinamically?
body: <p>i have this code:</p>
  
  <pre><code>function createfunc(i) {
      return function() {
          document.getElementById('id'+i).style.color='red';
          document.getElementById('id'+i).innerHTML = "Paragraph changed!";
      } 
  }
  function onDeviceReady() {   
      var olnew = document.createElement("ul");
      for (i = 0; i &lt; 10; i++){
          var newLi = document.createElement("li");
          var title = document.createElement('h2');
          title.id="id"+i;
          title.innerHTML = i;
          newLi.appendChild(title);
          newLi.onclick =createfunc(i);
          olnew.appendChild(newLi);
      }
  }
  </code></pre>
  
  <p>But when i click on the li element it not change the color or the text </p>
  
  <p>thanks very much</p>
  
  <p>UPDATE</p>
  
  <p>The original code is:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script&gt;
          function createfunc(i) {
          return function() {
             document.getElementById('id'+i).style.color='red';
             document.getElementById('id'+i).innerHTML = "Paragraph changed!";
                            } 
                                 }
          function onDeviceReady() {   
             var olnew = document.getElementById('ordenes');
             for (i = 0; i &lt; 10; i++){
                 var newLi = document.createElement("li");
                 var title = document.createElement('h2');
                 title.id="id"+i;
                 title.innerHTML = i;
                 newLi.appendChild(title);
                 newLi.onclick =createfunc(i);
                 olnew.appendChild(newLi);
                                     }
                     }
        &lt;/script&gt;
      &lt;/head&gt;
      &lt;body onload="onDeviceReady();"&gt;
          &lt;div id="layout"&gt;
              &lt;ul id="ordenes" &gt;&lt;/ul&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When i click the li, no change, the li elements have the id, but not work</p>