qq_慕先生1156968
2020-01-02 13:16
<script>
window.onload = function() {
var oTxt1 = document.getElementById('txt1');
var oTxt2 = document.getElementById('txt2');
var oBtn = document.getElementById('btn1');
oBtn.onclick= function() {
oTxt1.value += oTxt2.value + '\n';
oTxt2.value = '';
}
oTxt2.onkeydown= function(ev) {
var oEvent = ev || event;
//ctrlKey,shiftKey,altKey。
//其它按键用keyCode==*表示!
if(oEvent.ctrlKey&&oEvent.keyCode = =13 ) {
oTxt1.value += oTxt2.value+'\n';
oTxt2.value = '';
}
}
}
</script>
</head>
<body>
<textarea id="txt1" rows="10" cols="40"></textarea><br />
<input type="text" id="txt2" />
<input type="button" id="btn1" value="留言" />
</body>
DOM.innerText = '';
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题