【发布时间】:2014-04-14 18:50:14
【问题描述】:
我是流星和 js 的新手,但学习这些新东西并使用它非常令人兴奋。
我正在用它(以及其他东西:p)做一个小应用程序:
在我的 client.html 文件中:
<template name="input">
<form action={{submit}}>
<p>
Name : <input type="text" id="BibiName">
Message : <input type="text" id="BibiMessage">
<input type="submit" value="Toto">
</p>
</form>
</template>
在我的 client.js 文件中:
Template.input.submit = function () {
alert(document.getElementById("BibiName" ));
}
结果: 带有“null”的弹出窗口。
我做错了什么?
是因为 client.js 文件中的“提交函数”的执行发生在 client.html 中的“BibiName 输入”创建之前?
感谢您的提示
【问题讨论】:
-
是..元素必须存在于DOM中才能调用
getElementById否则返回null -
谢谢你。你能给我推荐一个教程,在那里我可以了解更多关于“首先执行什么元素,然后是第二个,......”?
标签: javascript html meteor