Save to localstorage onclick not working

Trying to save a variable from a textfield to localstorage onclick of a button but can’t seem to find my way out. When i click on the button and i go to check the localstorage section in chrome i found nothing

$('.save').on('click', function(event) {
        $username= $('#username')
        localStorage.setItem('username', $('#username').val());



<input type="text" name="username" id="username">
<input type="submit" name="button" id="button" value="Submit" class="save">

Source: html5

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.