这个提交按钮和后面的cltr+enter键怎么不能发布消息到Textarea?
 代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>71-留言发布框</title>
    <script>
        window.onload=function () {
            var oBtn=document.getElementById('btn1');
            var oTxt1=document.getElementById('txt1');
            var oTxt2=document.getElementById('txt2');

           oBtn.onclick=function(){
                oTxt2.vaule+=oTxt1.vaule+'\n';
                oTxt1.value='';
            };

          /*  oTxt1.onkeydown=function (ev) {
                var oEvent=ev||event;
                if(oEvent.keyCode==13&&oEvent.ctrlKey)
                {
                    oTxt2.vaule+=oTxt1.vaule+'\n';
                    oTxt1.value='';
                }
            };*/
        };
    </script>
</head>
<body>
<input id="txt1" type="text">
<input id="btn1" type="button" value="发布"><br/><br>
<textarea name="发布信息" id="txt2" cols="30" rows="10"></textarea>
</body>
</html>

2个回答

value都拼错了。。vaule==》value


        window.onload = function () {
            var oBtn = document.getElementById('btn1');
            var oTxt1 = document.getElementById('txt1');
            var oTxt2 = document.getElementById('txt2');
            oBtn.onclick = function () {
                oTxt2.value += oTxt1.value + '\n';///////
                oTxt1.value = '';
            };
            oTxt1.onkeydown = function (ev) {
                var oEvent = ev || event;
                if (oEvent.keyCode == 13 && oEvent.ctrlKey) {
                    oTxt2.value += oTxt1.value + '\n';////////////
                    oTxt1.value = '';
                }
            };
        }

我好粗心呀!@showbo

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问