Javascript – Clear local storage?

javascriptjquerylocal-storage

My online store uses local storage to store the cart. After the user has checked out, I want to clear it. However, localstorage.clear(); isn't working for me.

 $(document).ready(function(){
    $("#matkahuolto").live('click', function() {
        $(".maksu").slideDown(600);
        $("#matkahuolto").attr("disabled" , "disabled");
        $("#posti").removeAttr("disabled");
        $("#matkahuolto").addClass( "selectedtoimitus" );
        $("#posti").removeClass( "selectedtoimitus" );
        $(".simpleCart_shipping").html("15.00€");   
        localstorage.clear()


    });
 });

Best Answer

The correct spelling is localStorage - Javascript is case-sensitive:

localStorage.clear();

If this doesn't work because of a local variable, you'd need to use window.localStorage.