简体   繁体   English

另一个变量内的变量

[英]variable inside another variable

hi there i wanted to put this: 嗨,我想把这个:

document.write("y = " + i);

inside another variable, like this: 在另一个变量中,如下所示:

s=s+"\"y = \" \+ i";

but now, i variable is not variable, just a plain text. 但是现在,我的变量不是变量,只是纯文本。

how can i fix this? 我怎样才能解决这个问题? output would be 输出将是

document.getElementById("output").innerHTML=s;

thank you 谢谢

You do not pass to s string a variable - just text i . 您不能将字符串-只是文本i传递给s字符串。 Try with: 尝试:

s=s+"y = " + i;

You can also convert it to: 您也可以将其转换为:

s += "y = " + i;

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

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