提交按钮提交input type类型等标签内容到div中

    <script>
        window.onload=function(){
            var div1=document.getElementById("div1");
            var span1=document.getElementById("span1");
            var text1=document.getElementById("text1");
            var btn1=document.getElementById("btn1");

            btn1.onclick=function(){//匿名函数
                div1.innerHTML+=span1.innerHTML+text1.value+"<br/>";  //不想换行去掉<br/> 不想内容追加去掉+号
                text1.value="";//清除输入框内容
            }
        }
    </script>

</head>
<body>
<div ></div>
<span >苍老师:</span>
<input />
<input />
</body>
</html>

  

相关文章:

  • 2021-12-25
  • 2021-10-12
  • 2021-06-13
  • 2022-12-23
  • 2018-05-31
  • 2021-05-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
相关资源
相似解决方案