当按下父窗口上的按钮时,模态窗口会向下滑动。模态窗口有两个文本字段。用户输入完文本后,有一个“添加”按钮可以按下。我希望添加按钮填写 html 中的无序列表。我怎样才能将它传递给父母?
<div class="modal fade" id="newTask" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add a New Task</h4>
</div>
<div class="modal-body">
<form>
<input class="textField" type="text" placeholder="Enter the Task here."></input>
<input class="textField datepicker dueDate" id="dpd1" type="text" placeholder="Select Date">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="addListItem('list')" id="addTask">Add Task</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
$('.modal form').on('#newTask', function addListItem(listID){
var input = $('input[type=text]');
var str = '<li><table id="todoTable" border="1" cellspacing="2" cellpadding="3"><tr><td> <input type="checkbox" class="checkbox"> </input> </td><td> <input type="text" class="todo-data"> </input> </td><td> <input type="button" class = "image" value="X"> </input> </td></tr><tr><td> <input type="checkbox" class="no-show"> </input> </td> <script>$function(){$(".datepicker").datepicker();});</script> <td> <input type="text" id="datepicker" class = "datepicker"> </input> </td></tr></table></li>';
$('.todo-list').append(str);
input.val('');
$(this).parent().hide();
return false;
});