jQuery插件开发

1、类级别的插件开发

如$.get(),$.post的函数

方式一:

<script language="javascript">
 jQuery.myFun1 = function() {   
  alert('This is a test. This is only a test.');  
 };  
 jQuery.myFun2 = function(param) {   
  alert('This function takes a parameter, which is "' + param + '".');  
 };   
 //调用  
 $.myFun1();

 $.myFun2("test param");
</script>

方式二:

<script language="javascript">
jQuery.extend({      
 myFun1: function() {      
  alert('This is a test. This is only a test.');      
 },      
 myFun2: function(param) {      
  alert('This function takes a parameter, which is "' + param +'".');      
 }     
});  
 //调用  
 $.myFun1();
 $.myFun2("test param");
</script>

2、对象级别的插件开发

相关推荐