http://stackoverflow.com/questions/38070908/javascript-function-variable-always-undefined
by Aides
HTML
<div id="filterTitleTopic">
</div>
CSS
#filterTitleTopic
{
width: 200px;
height: 200px;
background-color: red;
}
JavaScript
var CTT;
$("#filterTitleTopic").click(function () {
console.log(CTT);
if (CTT == undefined || CTT == null || CTT == 2) {
$('input.topic').prop('checked', false);
CTT = 1;
console.log("unchecking boxes...");
}
else if (CTT == 1) {
$('input.topic').prop('checked', true);
CTT = 2;
console.log("checking boxes...");
}
});