<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="css/bootstrap.css" rel="stylesheet">
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.js"></script>
<style>
#text1{
background:yellow;
opacity:0.2;
display:none;
}
</style>
<script>
window.onload = function (){
var btnn = document.getElementById('btn');
var input = document.getElementById('input');
var text1 = document.getElementById('text1');
btnn.onclick = function () {
text1.innerHtMl =input.value;
text1.style.display='block';
};
};
</script>
</head>
<body>
<div class="container">
<h1 class='page-header text-center'>表单例子</h1>
<div class="row">
<div class='col-md-4 col-md-offset-4'>
<div class='input-group'>
<input type='text' id='input' class='form-control'>
<div class="input-group-btn">
<button id='btn' class='btn btn-default'>提交</button>
</div>
</div>
<textArea class='form-control' name='' id='text1'></textArea>
</div>
</div>
</div>
</body>
</html>
给某个标签赋值,向input、textarea这样的可以慧姐使用value属性。但是想div这样的标签则使用innerHtml