I have a issue. I want after each refresh, the previously selected row will be selected.
I have no idea for it. I tried localStorage but not work, maybe i'm wrong syntax. Help me!
My code:
$(document).ready(function () {
setInterval(ajax, 150000);
$('button').click(ajax);
function ajax() {
$.ajax({
type: "GET",
url: "demo.json",
success: function(result){
var output= "<table class='table'><tr><th>ID</th><th>Name</th><th>Type</th>";
for(var i=0; i<result.length-4;i++){
var ran = result[Math.floor(Math.random()*result.length)];
output+="<tr><td>" + ran.id + "</td><td>" + ran.name + "</td><td>" + ran.type + "</td></tr>";
}
output+="</table>";
var display = $('#root');
display.html(output);
$('tr').click(function(){
$(this).css('background-color','lightblue');
});
}});
};
});