csdnlaiyanqi
DreamsComeTrue1
2017-04-01 01:14

这个提交按钮和后面的cltr+enter键怎么不能发布消息到Textarea?

  • 函数
  • js
 代码如下:
<!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条回答