<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<script src="jquery.js"></script>
<script src="jqui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="jqui/jquery-ui.css">
<style type="text/css">
.dialog{
display: none;
}
</style>
<script type="text/javascript">
(function($){
$.fn.extend({
test:function(){
this.click(function(){
alert($(this).val())
});
},
dialogTest:function(){
var _this = this;
$('.dialog').dialog({
modal:true,
buttons:{
确定:function(){
rs = $('input[name=id]').val();
_this.html(rs);
$(this).dialog('close');
}
}
});
return this;
}
});
})(jQuery);
</script>
</head>
<body>
<div class="show"></div>
<button id="me">Click Me</button>
<div class="dialog">
<input type="text" name="id" placeholder="请输入ID">
</div>
<script type="text/javascript">
$('body').on('click', '#me', function(){
$('.show').dialogTest();
});
</script>
</body>
</html>
jQuery.fn.extend 可以写扩展插件
以上为Demo