html5 - Removing individual Item in LocalStorage not working using jquery? -


i'm trying remove individual item localstorage using jquery. i'm using localstorage storing data favorites. i'm displaying favorites in listivew. added checkbox selecting individual items in favorties delete tried alot delete selected checkboxes localstorage not working me.

my code:

function fromgetstorage() {     $("#favoriteslist").empty();       //$("#favoriteslist").addclass('current');     $("#favoriteslist").append('<input type="checkbox" name="all" id="select" />select all</br>');     $("#fav .ui-listview-filter").remove();      (var = 0; < localstorage.length; i++) {         var url = localstorage.key(i);         var item = localstorage.getitem(url);          $("#favoriteslist").append('<li id="add"><div><input type="checkbox" name="check" id="check">&nbsp;<a href="' + url + '" style="text-decoration:none;color:black">' + item + '</a></div></li>').attr('url', url);         $("#favoriteslist").listview('refresh');     }      $("#select").click(function(event){         event.stoppropagation();     });      $('#select').change(function() {         if ($("#select").is(':checked')) {             $("#add #check").prop("checked", true);             $('#empty').on('click', function() {                 localstorage.clear();                 $("#favoriteslist").listview('refresh');             });         }         else {             $("#add #check").prop("checked", false);         }     });      $("#add #check").click(function(event){         event.stoppropagation();     });      $("#add #check").change(function() {         var item = $(this);          $("#delete").on('click', function() {             if ($("#add #check").is(':checked')){                 // item.closest("li").remove();                 localstorage.removeitem(url);             }             $("#favoriteslist").listview('refresh');         });     }); }  

updated:

i'm updating code changes working not correctly.

$("#add #check").change(function() {         $("#delete").on('click', function() {             if($("#add #check").is(':checked')){                   var = $('input[name="check"]:checkbox:checked').length;                   if ( > 0)                   {                     var url = localstorage.key(i);                     localstorage.removeitem(url);                     $("#favoriteslist").listview('refresh');                   }              }             $("#favoriteslist").listview('refresh');         });  }); 

thanks in advance.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -