jquery插件——模拟dialog效果案例

jQuery插件开发全解析 jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法。jQuery 的全局函数就是属于jQuery命名空间的函数,另一种是对象级别的插件开发,即给jQuery对象添加方法。

<!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>
<link rel="stylesheet" href="./css/ui-lightness/jquery-ui-1.8.18.custom.css">
<script language="javascript" type="text/javascript" src="./js/jquery-1.7.1.min.js"></script>
<script language="javascript" type="text/javascript" src="./js/jquery-ui-1.8.18.custom.min.js"></script>
<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");//关闭对话框
			  
			  //alert("提交");
			  },
			  "取消":function (){
			  alert("取消的操作");
				  
				  
				  }
			
			
			},*/
			
			buttons:[{
				text:"ok",
				click:function(){
					$(this).dialog("close")
					}
			},
			{
				text:"取消",
				click:function(){
					$(this).dialog("close")
				
				}
				
				}],
			draggable:true,//是否可以拖动的效果 true可以拖动 默认值 true false代表不可以拖动
			closeOnEscape:false,//是否采用esc键退出对话框 如果为false则不采用 默认 true
			title:"添加标题操作页面",//对话框的标题
			position:"top",//对话框弹出的位置 可以使用 top left right center bottom 默认值 center
			width:600,//对话框的宽度
			height:300,
			resizable:false,//是否可以该表的操作 false则不可以改变尺寸 true可以改变尺寸 默认值是true
			zIndex:6,
			drag:function(event,ui){
				//可以测试出 对话框的当前坐标的位置
				
				
				}
		});
		//触发连接的事件 当你点击连接 打开一个对话框
	$("#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" class="ui-state-default ui-corner-all"><span >open dialog</span></a>
     <!--
   div对话框  $("#dialog").dialog();它就成了一个对话框 在页面中就会隐藏
   -->
     <div id="dialog" title="hi">
     
     hello!
     
     </div>
</body>
</html>


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值