-1

I have error with localStorage

Uncaught TypeError:localStorage.toggleSidebarCheck is not a function

I want to save the event when it clicked and although reload the page, the settings I click remain unchanged.

This my javascript:

$('.sidebar-toggle').click(function() {
    localStorage.setItem(toggleSidebarCheck).click();
});
Zayn Ali
  • 4,765
  • 1
  • 30
  • 40

1 Answers1

-3
$('.sidebar-toggle').click(function() {
    //assign your onclick result to one variable,like
    var toggleItem = "Hiiiii";

    //assign that variable to localStorage.setItem, like this
    localStorage.setItem('item', toggleItem);
});

// refresh page and see the alert message as Hiiiii

 alert(localStorage.getItem('item'));
Shiladitya
  • 12,003
  • 15
  • 25
  • 38
raj peer
  • 694
  • 6
  • 13