$("#blog-archive-button").on("click", function () { let archive = $('#blog-archive'); archive.toggle(); $(this).html((archive.is(":visible") ? "Hide" : "Show") + " archived posts"); }); $.ajax({ dataType: "json", url: "blog/posts.json", cache: false, success: function (json) { let list = $('#blog-list'); let archive = $('#blog-archive'); list.html(""); archive.html(""); for (let i = json.length - 1; i >= 0; i--) { var obj = json[i]; let p = ""; p += '