The list that gets appended to the div, how do I store them so that next time open my browser the appended elements remain as the previous state.
$('#try').prepend('<li class="list-group-item danger">' + $('#dat').html() + '</li>');
This is what I want to append.
//This is the empty div
<div id="dat" class="alert alert-danger">
</div>
/*below is my javascript code to append elements(ignore other functions)
this code basically appends the defects to the empty div*/
var queue = new Array();
function greet(greeting) {
console.log(greeting);
$('#dat').text(greeting);
}
function getRandom(arr) {
var rand = Math.random();
return arr[Math.floor(rand * arr.length)];
}
var greetings = [
"Hello 1",
"hello 2",
"hello 3",
"Hello 4",
"hello 5",
"hello 6",
"hello 7"
];
/*---------------------------*/
$(document).ready(function() {
ion.sound({
sounds: [
{ name: "glass" }
],
path: "Scripts/ui control/ring/",
preload: false,
volume: 10.0
});
setInterval(function() {
ion.sound.play("glass");
greet(getRandom(greetings));
$(".alert").fadeIn("fast").fadeOut(5000, function addMessage(msg) {
queue.push(msg);
$('#try').prepend('<li class="list-group-item danger">' + $('#dat').html() + '</li>');
if ($('.list-group-item').length > 9) {
//var msgToRemove = queue.shift();
//msgToRemove.remove();
$('.list-group-item:last').remove();
}
});
}, 8000);
});