[Solved] I have a list of names as , clicking on the name should save it to local storage… code attached [closed]


Try

Html

<ul class="namelist">
<li>Liam</li> 
<li>Noah</li> 
<li>William</li> 
<li>James</li> 
<li>Oliver</li> 
<li>Benjamin</li> 
<li>Elijah</li> 
<li>Lucas</li> 
</ul>
<div id="divShow">
</div>

Jquery

<script>
$('.namelist li').click(e=>{    
    localStorage.setItem($(e.currentTarget).text(), $(e.currentTarget).text());
    $('#divShow').append('<p>'+$(e.currentTarget).text()+'</p>');
});
</script>

3

solved I have a list of names as

  • , clicking on the name should save it to local storage… code attached [closed]