Try to use id instead class to refer in jQuery, leave the classes for CSS.
Check it here http://jsfiddle.net/hbzqnrm8/5/
I hope it helps you.
<button id="attack_enabled">ATTACK</button>
<button id="restore_enabled">RESTORE</button>
<div class="territory_middle_complete">ADD A CLASS HERE</div>
I've edited your jQuery code, and add what I think you want to achieve. Of course if you want to check the existance of the cookie when clicking the "restore" button, if not, just move the if condition wherever you needed, but not outside the click function, because it will be executed only on loading the file.
$("#attack_enabled").click(function(){
createCookie('attackcompletecookie','attack_cookie');
});
$("#restore_enabled").click(function(){
createCookie('restorecompletecookie','restore_cookie');
var atkcomplete = readCookie('attackcompletecookie');
if(atkcomplete)
{
alert(atkcomplete);
$(".territory_middle_complete").addClass("displayblockzindex2");
}
});
function createCookie(cookieName, cookieId) {
document.cookie = cookieName + '=' + cookieId;
}
function readCookie(name) {
var nameEQ = encodeURIComponent(name) + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length, c.length));
}
return null;
}