javascript - localstorage.clear() not working -


i writing post notes using html5 localstorage. somehow clear button not working. here code

    <form>     <input type="text" id="note_text">     <input type="button" id="add_button" value="add sticky note self">     <input type="button" id="clear_button" value="clear notes">  </form> <ul id="stickylist">  </ul> 

the js

    function init() {       var button = document.getelementbyid("add_button");     button.onclick = createsticky;     (var = 0; < localstorage.length; i++) {         var key = localstorage.key(i);         if (key.substring(0, 6) == "sticky") {             var value = localstorage.getitem(key);             addstickytodom(value);         }     } }   function addstickytodom(value) {     var sticky = document.createelement("li");     sticky.setattribute("class", "sticky");     var t = document.createtextnode(value);     sticky.appendchild(t);     document.getelementbyid("stickylist").appendchild(sticky);  }   function createsticky() {     var value = document.getelementbyid("note_text").value;     var key = "sticky_" + localstorage.length;     localstorage.setitem(key, value);     addstickytodom(value); }   function clearstorage() {     localstorage.clear();     cleart('cleaded stoegae'); }  var clearbtn=document.getelementbyid("clear_button"); clearbtn.onclick=clearstorage;   window.onload = init; 

here live fiddle fiddle

when click on clear button nothing. please tell me doing wrong. thanks,


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -