Something along the lines of ...? function myToggle(toggleElem, showHideElem){ var showHide = $(showHideElem); $(toggleElem).toggle( function(){ showHide.show('slow'); }, function(){ showHide.hide('slow'); } ); } myToggle('#regime_ltn_c', '#regime_ltn');
On Oct 31, 2:51 pm, Snook <[EMAIL PROTECTED]> wrote: > Hello, > > I use several time the same toggle function, like this: > > $("input#regime_ltn_c").toggle( > function() { > $("table#regime_ltn").show("slow"); > }, > function() { > $("table#regime_ltn").hide("slow"); > } > ); > > So I would like to create a function to improve my code. There is a > failure somewhere because this doesn't work: > > function display_regime(table_id) { > function() { > $(table_id).show("slow"); > }, > function() { > $(table_id).hide("slow"); > } > ); > > } > > $("#regime_ltn_c").toggle( > display_regime("table#regime_ltn"); > ); > > Thanks for your suggestions, > > Damien