Creating 26 alphabet letter buttons with the for loop and String.fromCharCode()

后端 未结 2 949
死守一世寂寞
死守一世寂寞 2021-01-28 07:46

here is some HTML Code as example:



<         


        
2条回答
  •  逝去的感伤
    2021-01-28 08:27

    Try this:

    var html = '';
    var c;
    for (var i = 65; 90 >= i; i++) {// A-65, Z-90
      c = String.fromCharCode(i);
      html += '';
    }
    document.getElementById('box').innerHTML = html;
    
    var setLetter = function(x) {
      document.getElementById('name').innerHTML += x;
    };

提交回复
热议问题