2
我知道這是一個非常簡單的問題div的,但我怎麼將內容添加到一個div當用戶鍵入到輸入字段,並按下了ENTER?添加內容根據輸入值
我曾嘗試:
document.addEventListener('keydown', function(e){
if(e.keyCode === 13) {
function bleh() {
var from = document.getElementById('setter').value;
x = document.getElementById("mything");
x.innerHTML = from;
}
}
})
我的HTML是:
<input type="text" autofocus="autofocus" id="setter"
onkeydown="writeit(this, event);moveIt(this.value.length, event)"
onkeyup="writeit(this, event)" onkeypress="writeit(this, event);"></input>
,如果你想看到它在行動,去thomaswd.com/cmd。開始打字並回車。
再次,這聽起來像一個非常簡單的問題,但我不能得到它的工作。謝謝!!!
哪裏是你的writeit功能?另外要注意,你似乎有一個全局變量'x' – Greg 2013-02-28 05:49:39
它的另一個JavaScript文件,但它與此無關 – 2013-02-28 05:50:33
您的div或輸入元素在內容頁面中? – Karamafrooz 2013-02-28 05:51:40