我在对话框中创建了一个动态 div 和段落,以在提交表单时显示确认。如何在动态 div 中附加动态段落,请帮助我。
提前致谢。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Jquery Confirm Dialog</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="JQUERY/jquery-ui.js"></script>
<style type="text/css">
.ui-dialog .ui-dialog-titlebar, .ui-dialog .ui-dialog-buttonpane { font-size: 0.8em; }
</style>
<script type="text/javascript">
$(document).ready(function ()
{
$("#ShowDivPopup").click(function ()
{
var DynamicDiv = $('<div id="dynamicPopupDiv" style="width: 340px;height: 380px;background-color:#fff;display: none"></div>');
var Message = $('<p>Are you Sure</p>');
$('body').append(DynamicDiv);
$('#DynamicDiv').append(Message);
$("#dynamicPopupDiv").dialog(
{
modal: true,
height: 180,
width: 320,
title: 'Info',
closeOnEscape: false,
resizable: false,
draggable: true,
buttons: {
"Ok": function ()
{
alert("Submit form ");
},
"Cancel": function ()
{
$(this).dialog('close');
}
}
});
});
});
</script>
</head>
<body>
<form id="myForm" method="post" action="return welcome()">
<div id="ConFirmDiv" style="width: 340px;height: 380px;background-color:#fff;display: none">
<span>Are You Sure Want to Submit</span>
</div>
<input type="button" id="ShowDivPopup" value="Show Popup" />
</form>
</body>
</html>