<!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>jquery控件学习</title>
<script type="text/javascript" src="http://libs.useso.com/js/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
//控件
$.fn.test=function(options){
var optionThis=$(this);
defaultoptions={
closeBtn:‘#closeBtn‘
};
even={
open:function(){
optionThis.unbind().bind(‘click‘,function(){
$(‘body‘).append($(‘<div class="layer">‘).text(‘这是一个层‘));
even.close();
});
},
close:function(){
$(defaultoptions.closeBtn).unbind().bind(‘click‘,function(){
$(‘.layer‘).remove();
});
}
};
even.open();
};
$(document).ready(function() {
$(‘#openBtn‘).test({});
});
</script>
</head>
<body>
<input type="button" value="open" id="openBtn"/>
<input type="button" value="close" id="closeBtn"/>
</body>
</html>