I have some values i am trying to store in local storage using key:value
pairs. I want the key
to be a random value from Math.random()
but my value is not being seen as a variable
This is the fiddle
https://jsfiddle.net/ps4xs60x/27/
and the code
$(document).ready(function () {
$(document).on('click', '.btn-primary', function(){
var num = Math.random();
$('.table tbody').append('<tr class="child"><td>one</td><td><button id="'+num+'" onClick="ae(this.id); function ae(clicked_id) {var items = []; var entry = {\'num\': clicked_id}; items.push(entry);localStorage.setItem(\'entry\',JSON.stringify(items));alert(localStorage.getItem(\'entry\',JSON.stringify(items)));}" type="button" class="invite ">Invite</button></td></tr>');
});
});
How can i make num
to be seen as a variable?