我正在尝试从 HTML 文件中获取用户输入,对其进行转换,然后使用 <input>
将其输出回页面。而不是提示。
这是我到目前为止所拥有的。
function bhedTester() {
alpha = "ABC";
bhed = "JYI";
btext = "";
i = 0;
while (i < norm.length) {
ind = alphabet.indexOf(norm.charAt(i));
btext = btext + bhed.charAt(ind);
i++;
}
btext
}
我已经使用提示命令对此进行了测试并且它有效,但是当我使用时
document.getElementById
或者
document.form_name._input_name.value
然后返回似乎都不起作用。
谁能给点建议吗?
最佳答案
如果您从 DOM 事件触发此函数,则必须返回 btext。
function bhedTester() {
var alpha = "ABC";
var bhed = "JYI";
var btext = "";
var i = 0;
while (i < norm.length) {
var ind = alphabet.indexOf(norm.charAt(i));
btext = btext + bhed.charAt(ind);
i++;
}
return btext
}
关于javascript - JS 函数的用户输入到输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40597111/