js闭包
<script>
(function(document){
var viewport;
var obj = {
init:function(val){
viewport = val;
},
add:function(){
viewport = viewport + 1;
},
get:function(){
return viewport;
}
}
window.jView = obj;
})(document);
jView.init(8);
jView.add();
alert(jView.get());
</script>
JQuery插件模板
;(function($) {
$.fn.superGallery = function(options) {
var defaults = {
textColor: "#000",
backgroundColor: "#fff",
fontSize: "1em"
};
var settings = $.extend( {}, defaults, options );
return this.each(function() {
});
};
}(jQuery));