Skip to content Skip to sidebar Skip to footer

Clear Local Storage For Div On Radio Selection

I'm trying to get local storage to clear for all fields in one specific div when the user selects the No radio button: Slightly incomplete jsfiddle but should do the trick I'm obvi

Solution 1:

localStorage is not a jQuery method . Also

$(document).ready([function() {

    if (localStorage["dontclear"]) {
      $('#dontclear').val(localStorage["dontclear"]);
    }
    if (localStorage["fname"]) {
      $('#fname').val(localStorage["fname"]);
    }
    if (localStorage["lname"]) {
      $('#lname').val(localStorage["lname"]);
    }
  console.log(localStorage)
}, function() {
  $('.stored').change(function() {
    localStorage[$(this).attr('name')] = $(this).val();
    console.log(localStorage)
  });

  $('input[name="for_person"]').on('click', function() {
    if ($('#personNo').prop('checked')) {
      // ??localStorage.removeItem('fname');

    } else {

      // do nothing

    }
  });
}]);

plnkr http://plnkr.co/edit/LPw3zbpgrhJkSh1hdKXG?p=info

Post a Comment for "Clear Local Storage For Div On Radio Selection"