'innerHTML' undefined

1

I need help, I can not get it to work.

var valu=document.getElementsByClassName("user-coins-value middle-block")[0];
var yesno=confirm("You have access key ?");
if(yesno==true)
    {
    var enter_key=prompt("Enter access key",'Example: 43ML9923');
    if(enter_key==".")
        {
        alert("OK\nNotice in 5 seconds!");
        setTimeout(function()
            {
            var enter_coins=prompt("Enter value of coins",'Min: 1000, Max: 75000');
            var timer=setInterval(function()
                {
                var i=document.getElementsByClassName("user-coins-value middle-block")[0].innerHTML;
                i++;
                valu.innerHTML=i++;
                if(valu.innerHTML==enter_coins)
                    {
                    clearInterval(timer);
                    alert("It's all\nGood buy")
                }
            }
            ,25)
        }
        ,5000)
    }
    else
        {
        alert("Wrong ACESS KEY")
    }
}
    
asked by anonymous 29.06.2017 / 05:24

1 answer

1

Your code is working perfectly, what you have to ensure is that the HTML does not contain any spaces or other types of characters other than numbers inside. Example: If your code looks like this:

  <div class="user-coins-value middle-block">
     5
  </div>

Switch to:

 <div class="user-coins-value middle-block">5</div>
    
29.06.2017 / 14:18