SinhaengHhjian 2015-11-04
$("#dialogDiv").dialog();
$("#dialogDiv").dialog({ autoOpen : false, // 是否自动弹出窗口 modal : true, // 设置为模态对话框 resizable : true, width : 410, //弹出框宽度 height : 240, //弹出框高度 title : "用户登录", //弹出框标题 position : "center", //窗口显示的位置 buttons:{ '确定':function(){ //调用登录的方法 }, '取消':function(){ $(this).dialog("close"); } } });
1 | $( "#dialogDiv" ).dialog( "open" ); |
1 2 3 4 5 | <input type= "button" id= "login" value= "点击登录" /> <div id= "dialogDiv" style= "text-align: center;padding-top: 24px" > <label>帐号:</label><input type= "text" id= "user" /><br> <label>密码:</label><input type= "password" id= "password" /><br> </div> |
A simple jQuery UI Dialog
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>dialog demo</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> </head> <body> <button id="opener">open the dialog</button> <div id="dialog" title="Dialog Title">I'm a dialog</div> <script> $( "#dialog" ).dialog({ autoOpen: false }); $( "#opener" ).click(function() { $( "#dialog" ).dialog( "open" ); }); </script> </body> </html>
注: 这里没有document.ready 里面,而是直接在<script>里面写的
效果:
来自:http://api.jqueryui.com/dialog/#entry-examples