问答详情
源自:9-1 认识DOM

做好提交内容框后怎么在此基础上做清空文本框内容


<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>


提问者:qq_慕先生1156968 2020-01-02 13:16

个回答

  • 野生Monk3y
    2020-04-22 01:58:07

    DOM.innerText = '';