jQuery插件的写法

   jQuery.fn.extend({   
      check:
function(mode)
      
{
        
var mode = mode || 'on';
        
return this.each(function(){
          switch(mode)
{
            
case 'on':
             
this.checked=true;
             
break;
            
case 'off':
             
this.checked=false;
             
break;
            
case 'toggle':
             
this.checked=!this.checked;
             
break;
          }

        }
);
      }

   }
);
   
当你看了jQuery里面的代码和API,就知道是什么回事了.是不是更微软的Ajax Library的写法类似呢!
这个是全选和取消全选的方法.调用方法: $("input[@type='checkbox']").check('toggle');

附录:
CSS编写软件:TopStyle
JavaScript:调试器:FireFox的venkman
posted @ 2007-03-21 17:00  永不言败  阅读(1742)  评论(2编辑  收藏  举报