我有这个功能:
function msj(str) {
// display = document.getElementById("txt"); // DOM
// nodo = document.createTextNode(str);
// display.replaceChild(nodo,display.firstChild);
$("#txt").html(str); // jQuery
}
消息显示在此处:
<div id="txt">Guess the number between 1 and 10</div>
然后,我想将消息显示到输入文本表单中。有谁知道怎么做吗?
非常感谢。
最佳答案
尝试
<input type="text" id="txt" />
function msj(str) {
$("#txt").val(str); // jQuery
}
关于JQuery html字符串输入框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16755541/