How to write a reusable jquery click function?
问题 I have this accordion function : $('.accordion a').click(function () { if($(this).is('.accordionClose')) { $('.accordionOpen').toggleClass('accordionOpen').toggleClass('accordionClose').next().slideToggle().toggleClass('openContent'); $(this).toggleClass('accordionOpen').toggleClass('accordionClose'); $(this).next().slideToggle().toggleClass('openContent'); } else { $(this).toggleClass('accordionOpen').toggleClass('accordionClose'); $(this).next().slideToggle().toggleClass('openContent'); } }