单击按钮后,我无法将值传递给引导程序模式
我有一张桌子,其中一个tr如下所示
"<td><input type='button' value='Delete' id='deletetopicDetsId" + val.TopicDetailsId +
"'class='btn btn - primary' **onclick = DeleteConfirmation(event) data-toggle='modal' data-target='#deleteConfirmation_modal_id'></td>**";
并且JS代码如下
function DeleteConfirmation(val) {
var _topicId = val.target.id.replace('deletetopicDetsId', '');
$(".modal-body #deleteConfirm_topicId").val(_topicId);
}
function DeleteCancel() {
console.log($(".modal-body #deleteConfirm_topicId").val());
$(".modal-body #deleteConfirm_topicId").val('');
$('#deleteConfirmation_modal_id').modal('hide');
console.log($(".modal-body #deleteConfirm_topicId").val());
}
我的html如下
<div class="modal fade" id="deleteConfirmation_modal_id" tabindex="-1" role="dialog" aria-labelledby="deleteConfirmation_modal_label" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete Confirmation!</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="newRTVal" class="col-form-label">Are you sure you want to Delete ?</label>
</div>
<div id="deleteConfirm_topicId" hidden="hidden"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="DeleteCancel()">No</button>
<button type="button" class="btn btn-primary" onclick="Delete()">Yes</button>
</div>
</div>
</div>
</div>