第一种
js:
(function (jQuery){
this.show =function(title){
this.title=title;
};
this.show2 =function(){
alert(this.title);
};
jQuery.messager =this;
return jQuery;
})(jQuery);
html:
Code
<script src="jquery.js"></script>
<script src="js.js"></script>
<script>
$(document).ready(function(){
$.messager.show("this is a test");
$.messager.show2();
});
</script>
第二种
js:
Code
$.fn.messager =function(options){
var defaults = {
title:"this is a test!"
};
$.extend(defaults,options);
alert(defaults.title);
returnthis;
};
html:
Code
<script src="jquery.js"></script>
<script src="js.js"></script>
<script>
$(document).ready(function(){
$("#d").messager().hide();
});
</script>