JQuery causing fadeIn twice? -
i trying achieve effect when click new item clicked item fadeout. when click same item twice fades in again, , not fade in twice.
since still learning js please add reasoning why mine isnt working , needs done achieve it, able self learn better :)
i wast able load code input module here code:
jquery(document).ready(function() { jquery(".qs").click(function() { jquery(".qs").siblings(".ans").fadeout(600).not(jquery(this)); jquery(this).siblings(".ans").fadein(600); }); }); <table class="faqs" style="width:100%"> <tr> <td class="qs"><span>1. how lenden work?</span></td> <td class="ans">this example answer more length testing.</td> </tr> <tr> <td class="qs"><span>2. different modes of transaction?</span></td> <td class="ans">answer</td> </tr> </table>
thanks guys.
alex
if understood question correctly, might solve problem:
jquery(document).ready(function() { jquery(".qs").click(function() { if(jquery(this).hasclass("selected")){ return; } jquery(".qs").siblings(".ans").fadeout(); jquery(this).siblings(".ans").fadein(); jquery(".qs").removeclass("selected"); jquery(this).addclass("selected"); }); });
you need css:
<style> .active .units { display:block } .ans {display: none} .selected{} </style>
ofcourse there couls better ways of doing it.