버튼을 클릭 한 후 새 텍스트를 추가하고 매번 입력 할 버튼이 필요합니다.버튼을 클릭 한 후 새 입력 추가
버튼을 누른 후 원하는 출력을 한 번 클릭하십시오.
하지만 내 다음 코드를 부여, 나의 새로운 입력은 초기 입력을 무시합니다.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Table</title>
</head>
<body>
<table>
<tbody>
<tr>
<td>Input
<input type="text" class="form-control" readonly="readonly">
</td>
</tr>
</tbody>
</table>
<div class="form-group row" style="padding-top: 10px">
<div class="col-md-1 text-center">
<button id="addnewinputbtn" name="button" class="btn btn-default">Add New Input</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#addnewinputbtn').click(function() {
$('tr').appendTo('tbody')
.html(
'<td>New Input <input type="text" class="form-control" readonly="readonly"></td>');
});
});
</script>
</body>
</html>
코드 –