How to save the user input table data in to local storage using JavaScript.
I want to save user input in local storage,
Please see my code that I have tried,
<script type="text/javascript">
function getValue(){
var selectedText = $("#ddlFruits").find("option:selected").text();
if(selectedText!="None"){
var display = document.getElementById("display");
$('#display tr:last').after('<tr><th>'+selectedText+'</th></tr>');
document.getElementById('ddlFruits').selectedIndex = 0;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<select id="ddlFruits" onchange="getValue();">
<option value="">None</option>
<option value="1">Apple</option>
<option value="2">Mango</option>
<option value="3">Orange</option>
</select>
<table border="1" id="display">
<tr>
<th>Fruits</th>
</tr>r>