HTML 代码:
<!-- Modal -->
<div class="modal fade" id="myModal">
<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">Book return comment (optional):</h4>
</div>
<div class="modal-body">
<textarea id="comment" class="form-control" rows="6" maxlength="500" placeholder="Please limit your comment to 500 characters."></textarea>
</div>
<div class="modal-footer">
<a href="#" id="btn-confirm" class="btn">Confirm</a>
<a href="#" class="btn">Cancel</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="commentField">
</div>
JS:
function getComment () {
var comment = $('#comment').val();
$('#commnetField').html(comment);
}
$('#btn-confirm').click(function() {
});
我是 jQuery 的新手,这段代码有什么问题?我想获取 textarea 文本并将其显示在 id='commentField' 的 div 中。