有没有一种使用jquery在按钮点击时创建弹出窗口中的表单的方法?表单将具有几个输入字段和“保存”和“取消”按钮。因此,在点击“保存”时,表单中的信息将保存在数据库中,并返回到原始屏幕。我想要一个淡入弹出窗口。
使用这段代码
HTML
<div id="divdeps" style="display:none" title=""></div>
jQuery在DOM准备就绪时
$("#divdeps").dialog({
autoOpen: false,
show: 'slide',
resizable: false,
position: 'center',
stack: true,
height: 'auto',
width: 'auto',
modal: true
});
以下代码将初始化一个对话框并使其处于准备打开和关闭的状态。如果您想要在页面加载时打开对话框,则只需在文档就绪后添加此行代码:
$("#divdeps").dialog('open');
这里是一个使用JQuery的示例。您可以查看其他类型的弹出窗口对话框的详细信息。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Animation</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#opener" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
} );
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<button id="opener">Open Dialog</button>
</body>
</html>
<div id=form>
your form here
</div>
然后调用对话框实例(可能将其链接到某种单击处理程序以触发表单)
$('#form').dialog({
modal: true,
buttons:
{ "Cancel": function() {
$(this).dialog("close")
},
"Submit": function() {
//put code here for form submission
}
});
http://blog.nemikor.com/2009/04/08/basic-usage-of-the-jquery-ui-dialog/
。 - Lorenzo
http://jsbin.com/ugetu3
- Lorenzo