JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="textarea"></textarea>
<button id="add">Add</button>
<button id="clear"> Delete</button>
<div id="list"></div>
JavaScript
$("#add").click(function() {
var userList = $('#textarea').val();
$('#textarea').val('');
var newitem ='<p contenteditable="true">'+userList +'</p>';
$('#list').append(newitem);
var list=$("#list").html();
localStorage.setItem('list', list);
return false;
});
if (localStorage.getItem('list')) {
$('#list').html(localStorage.getItem('list'));
}
$("p[contenteditable]").keypress(function (evt) {
var keycode = evt.charCode || evt.keyCode;
if (keycode == 13) {
return false;
}
});
$('#clear').click(function() {
window.localStorage.clear();
window.location.reload();
return false;
});