<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript" src="../include/jquery.js"></script>
<script language="javascript" type="text/javascript" src="../include/jquery-ui-1.8.18.custom.min.js"></script>
<link rel="stylesheet" href="../include/jquery-ui.css" />
<script type="text/javascript">
//$(document) 把dom对象转换成jQuery对象
//.ready(function(){});
//当窗体加载完毕的时候 触发该匿名函数
$(function(){
//注册对话框
$("#dialog").dialog({
autoOpen:false, //设置对话框打开的方式 不是自动打开
show:"blind", //打开时的动画效果
hide:"explode", //关闭时的动画效果
modal:true, //true遮罩效果 false非遮罩效果
/*buttons:{ //添加按钮的操作
"确定":function(){
$(this).dialog("close"); //关闭对话框
},
"取消":function(){
alert("取消操作");
}
},*/
//buttons的第二种写法
buttons:[{
text:"ok",
click:function(){
$(this).dialog("close");
}
},
{
text:"return",
click:function(){
$(this).dialog("close");
}
}],
draggable:false, //是否可以拖动的效果 true可以拖动 默认值就是可以拖动 false代表不可用拖动
closeOnEscape:false, //是否采用esc键退出对话框 false不采用 true采用 默认是true
title:"添加用户操作界面", //对话框的标题
position:"top", //对话框弹出的位置 可以使top right left center bottom 默认值是center
width:600, //对话框宽度
height:200, //对话框高度
resizable:false, //尺寸 false不可用改变 true可以改变 默认值true
zIndex:6, //
drag:function(event,ui){
//可以测试出 对话框的当前坐标位置
alert("你敢拖拽,我就执行!");
}
});
//触发连接的事件 当你点击 连接 打开一个对话框
$("#dialog_link").click(function(){
$("#dialog").dialog("open"); //open参数 作用 打开对话框
});
//我怎么获取 我设置的options中的参数值
var modalValue = $("#dialog").dialog("option","modal");
alert(modalValue);
//我怎么设置options 中的参数值
$("#dialog").dialog("option","modal",false);
});
</script>
</head>
<body>
<h1>模拟Dialog效果</h1>
<!--创建一个连接-->
<a href="#" id="dialog_link"><span></span>Open Dialog</a>
<!--对话框 $("#dialog").dialog(); 它就成了一个对话框 在页面中就会隐藏-->
<div id="dialog" title="hi">
hello,
</div>
</body>
</html>
jquery对话框
最新推荐文章于 2023-04-10 08:53:48 发布