2010-03-13 67 views
0

帮助将不胜感激。什么是正确的标记,将这个功能变成一个插件。我尝试过,但无法使其工作。jquery更改功能代码为插件

$(文件)。就绪(函数(){
$( 'ul.tabNav一个')。点击(函数(){
VAR curChildIndex = $(本).parent()。prevAll() ()。current + 1;
$(this).parent()。parent ');
$(this).parent()。parent()。next('.tabContainer')。children('。current')。slideUp('fast',function(){
$(this) .removeClass('current');
$(this).parent()。children('div:nth-​​child('+ curChildIndex +')')。slideDown('normal',functi on(){
$(this).addClass('current');
});
});
返回true;
});
});

回答

0
(function($) { 

    jQuery.fn.pluginName = function() { 

      return this.each(function() { 

         Your Code; 
     }); 
    }; 
})(jQuery); 
+0

谢谢你这个非常明确的答案。但是,我如何从我的html中调用插件? –

+0

我在这个论坛上发现了一个类似的问题来回答我的问题。谢谢你的帮助。 http://stackoverflow.com/questions/2157651/help-turning-jquery-script-into-a-plugin –