【发布时间】:2010-12-13 11:10:32
【问题描述】:
我想稍后在同一脚本中引用字段中的变量(“特殊”)。我已经让变量显示在警告框和 document.write 中,但现在不知道如何将其值应用于
中的值字段var special=(10000-health);
var health=(100);
<input style="background:#FF7777;" readonly="readonly" type="text" value="special" id="special" />
当我想要这个值时,这只是将“特殊”写入盒子。
【问题讨论】:
-
您在定义之前引用了
health。您可能希望将var health=(100);移到special的声明上方。
标签: javascript variables