I also have tried, like you suggested, to use the .each() function. function myToggle(toggleElem, showHideElem){ var showHide = $(showHideElem); $(toggleElem).toggle( function(){ showHide.show('slow');}, function(){ showHide.hide('slow');} ).each(function() { if ($(toggleElem).is(":checked")) { $(this).attr("checked", ""); } else { $(this).attr("checked", "checked"); } }); }
But this is not successful ! On Nov 3, 1:15 am, Wizzud <[EMAIL PROTECTED]> wrote: > function myToggle(toggleElem, showHideElem){ > var showHide = $(showHideElem); > $(toggleElem).toggle( > function(){ showHide.show('slow'); }, > function(){ showHide.hide('slow'); } ) > .each(function(){ this.checked = !this.checked; }); > > } > > On Nov 2, 12:21 pm, Snook <[EMAIL PROTECTED]> wrote: > > > > Calling toggle() runs event.preventDefault. > > > Whatever you want the click to do, you need to code it yourself. > > > Ok, thanks. > > I have tried different implementation of preventDefault, regarding > > what I have found in this group. And probably I'm completely wrong > > because no one works for me. > > > Here is what I have tried: > > > function myToggleShow(toggleElem, showHideElem){ > > var showHide = $(showHideElem); > > $(toggleElem).toggle( > > function(e){ > > e.eventDefault(); > > showHide.show('slow'); > > }, > > function(){ showHide.hide('slow'); } > > > ); > > > } > > > myToggleShow('#regime_lstd_c', '#regime_lstd'); > > > Did I need an other plugin or library ?