title: JavaScript: Module based Todo list needs simplification
body: <p>This is my todo list based on the Module Pattern, this is working fine and just want to know two things. </p>
  
  <p>Is this code still can be simplified?
  Once I added a list, if i refresh the page, then, these list are gone, but, my requirement is, these lists are deleted when i use 'Remove List'. How I can amend this? Any advise?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt; TO-Do List In Javascript &lt;/title&gt;
      &lt;style&gt;
      #message{
      left: 0px;
      margin-left: 10px;
      }
      div#todo &gt; div input {
      top:-39px;
      margin-left: 226px;
  
      position: relative;
      }
      div#todo &gt; div &gt; p {
          padding: 0px;
          width: 210px;
  
      }
      div#todo  div {
      top:0px;
      padding:0px;
      margin:0px;
      }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
    &lt;div id="itemin"&gt;&lt;input type="text" id="txt1" name="text1"/&gt;&lt;input type="button" id="bt1" value="Add List"/&gt;&lt;input type="button" id="bt2" value="Remove List"/&gt;&lt;/div&gt;
   &lt;div id="todo"&gt;
   &lt;/div&gt;
      &lt;script type="text/javascript"&gt;
      var Todo = Todo || {};
  
  var element = document.getElementById("todo");
  var elementChiCount="";
  
  Todo.Item = (function(){
  
         function creatList(someInput) {
  
         elementChiCount = element.getElementsByTagName("div").length;
  
           var txtNode = document.createTextNode(someInput);
           var elemNode = document.createElement("p");
           elemNode.appendChild(txtNode);
  
           var elemCheckbox = document.createElement("input");
  
           elemCheckbox.setAttribute("id", 'check'+ elementChiCount);
           elemCheckbox.setAttribute("type", 'checkbox');
  
           var divElem = document.createElement("div");
            divElem.appendChild(elemNode);
            divElem.appendChild(elemCheckbox);
  
           divElem.setAttribute("id", "item"+elementChiCount);
           divElem.setAttribute("style", "border: 1px solid pink; width: 250px;padding-left:10px");
           element.appendChild(divElem);
  
       }
       function addList(txtInput) {
           creatList(txtInput);
       }
         function deleteList() {
           elementChiCount = element.getElementsByTagName("div").length;
           for (var i = 0; i &lt; elementChiCount; i++) {
  
             var elementCurr = element.getElementsByTagName("div")[i];
  
           if(elementCurr.getElementsByTagName("input")[0].checked == true){
            var thisElem = elementCurr.parentNode;
           thisElem.removeChild(elementCurr);
           break;
           } else {
           }       }
  
       }
  
      return {
        add: addList,
        del: deleteList
  
      }
  })();
  
  
      &lt;/script&gt;
   &lt;script type="text/javascript"&gt;
   var actBtn = document.getElementById("bt1"); 
   var delBtn = document.getElementById("bt2"); 
  
   actBtn.onclick = function() {
   var txtVaue = document.getElementById("txt1").value;
   Todo.Item.add(txtVaue);
  }
  
  delBtn.onclick = function() {
   Todo.Item.del();
  }
  &lt;/script&gt;
  
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>