简体   繁体   English

“ Hangman”游戏。 题词显示为“ tresc_diva”,而不是字母

[英]“Hangman” game. Instead of letters, the inscription is displayed “tresc_diva”

I have function: 我有功能:

function start() { 函数start(){

var tresc_diva = "";

for (i=0; i<34; i++) {

    tresc_diva = tresc_diva + '<div class="litera">A</div>';


}

document.getElementById("alfabet").innerHTML = "tresc_diva"; 

wypisz_haslo();

} }

The whole code: https://codepen.io/Nieuport/pen/bWRMdR 整个代码: https : //codepen.io/Nieuport/pen/bWRMdR

This line 这条线

document.getElementById("alfabet").innerHTML = "tresc_diva";

Sets the innerHTML to the string "tresc_diva". 将innerHTML设置为字符串“ tresc_diva”。 You probably simply want to remove the quotes: 您可能只想删除引号:

document.getElementById("alfabet").innerHTML = tresc_diva;

您正在将字符串“ tresc_diva”分配给innerHTML属性,您想分配tresc_diva变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM