daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. localStorage.getItem(...).key is not a function
  2.    
  3. $(document).ready(function(){
  4.     //var count=localStorage.getItem("todo").length;
  5.     $(".submit").click(function(){
  6.         //count++;      
  7.  
  8.         localStorage.setItem("todo", JSON.stringify($('.data').val()));
  9.  
  10.  
  11.         var i;
  12.         while (localStorage.getItem("todo").key(i)) {
  13.             var value = "<div class='todorow'><div class='todoitem'>"+JSON.parse(localStorage.getItem("todo").key(i))+"</div><div class='todoremove'>X</div></div>";
  14.             $(".container").append(value);
  15.             console.log(localStorage.getItem("todo").key(i));
  16.             i++;
  17.         }
  18.  
  19.     });
  20.     $(".container").on("click", ".todoitem", function(){
  21.         jQuery(this).addClass("strike");
  22.     });
  23.     $(".container").on("click", ".todoremove", function(){
  24.         jQuery(this).closest('.todorow').addClass("hide");
  25.     });
  26.  
  27.     var i;
  28.     while (localStorage.getItem("todo").key(i)) {
  29.             var value = "<div class='todorow'><div class='todoitem'>"+JSON.parse(localStorage.getItem("todo").key(i))+"</div><div class='todoremove'>X</div></div>";
  30.             $(".container").append(value);
  31.             i++;
  32.     }
  33.  
  34. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top