2010-03-13 5 views
0

Aide serait grandement appréciée. Quel est le balisage correct qui changerait cette fonction en un plugin? J'ai essayé, mais je ne peux pas le faire fonctionner.jquery changer la fonction dans le code pour le plugin

$ (document) .ready (function() {
$ ('ul.tabNav a'). Cliquez sur (function() {var
curChildIndex = $ (this) .parent(). PrevAll() .length + 1;
$ (this) .parent(). parent(). children ('.courant'). removeClass ('current');
$ (this) .parent(). addClass ('current
$ (this) .parent(). Parent(). Next ('. TabContainer'). Children ('.courant'). SlideUp ('rapide', function() {
$ (this) .removeClass ('current');
$ (this) .parent(). enfants ('div: nth-child (' + curChildIndex + ')'). slideDown ('normal', foncti on() {
$ (this) .addClasse ('current');
});
});
return true;
});
});

Répondre

0
(function($) { 

    jQuery.fn.pluginName = function() { 

      return this.each(function() { 

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

Merci pour cette réponse très claire. Mais comment puis-je appeler le plugin à partir de mon code HTML? –

+0

J'ai trouvé une question simulée sur ce forum qui a répondu à ma question. Merci de votre aide. http://stackoverflow.com/questions/2157651/help-turning-jquery-script-into-a-plugin –

Questions connexes