如何把javascript的结果

How to put the outcome of a javascript

本文关键字:结果 javascript      更新时间:2023-09-26

我正在运行一个函数,它是翻译一些俚语/缩写短语到真正的英语单词。函数字(){var text= document.getElementById("textbox1").value;For (var i=0;我

}
</script>
</body>
</H2>
</HTML>

正如你可能看到的,我有一个CSS样式表附件。我也会把这个贴出来,以防它能帮助任何人解决我的问题!

/* CSS Document */
body {
 background-color: #616161;
 font-size: 20px;
color: WHITE;
font-family:"Goudy Stout"; 
 }
h2 {
font size: 11px;
color: balck;
font-family: Calibri;
}

用以下行替换警告:

document.getElementsByClassName('textbox')[1].value=text
// 1. You need to get the <input class=textbox>
// document.getElementsByClassName('textbox')
// 2. This will return an array, you need the second Element [2]
// .value=text

将alert替换为以下代码

var elems = document.getElementsByClassName("textbox");
elems[1].value = text;

还有另一种简单的方法。为文本框指定一个Id,并写入以下行

<input type= "text" class="textbox" value= "Translation should appear here"></input>
var elem = document.getElementById("textbox");
elem.value = text;