<script>
!function () {
var elem = document.getElementById('win');
var child = elem.getElementsByClassName('inviz');// TypeError: elem is null
var button = document.getElementById('getdiv');
var leng = child.length;
var i = 0;
button.onclick = function (e) {
if (i >= leng) return;
child[0].className = 'happyend';
i++;
return false;
}
}();
</script>