<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>时代Java与您共同学习(NowJava.com)</title>
<script src="https://cdn.staticfile.org/jquery/1.6.2/jquery.min.js"></script>
</head>
<body>
<div id='main' style="display:none">Main</div>
<script>
(function() {
// 使用sub()创建jquery副本
var plugin = jQuery.sub();
// 拓展该副本新方法
plugin.fn.extend({
open: function() {
return this.show();
},
close: function() {
return this.hide();
}
});
// 添加插件到原jquery
jQuery.fn.myplugin = function() {
this.addClass("plugin");
// 确认插件返回特殊插件版本(副本)
return plugin(this);
};
})();
$(document).ready(function() {
// 执行插件,open方法存在
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。