jquery - How can i detach elements and then show then with fadeIn / fadeOut on click -


i put fadein fadeout (instead of show/hide) , when tried content jumps prev element residing , , not want use position absolute content. how can use animate in same manner following ? detach them on , undo detach on click ?

http://jsfiddle.net/zm9dl/514/

$('.menu>li').on('click',function(e){     $('.container>.'+ e.target.classlist[0]).show().siblings().hide(); }); 

html

<ul class="menu">     <li class="toggle1">one</li>     <li class="toggle2">two</li>     <li class="toggle3">three</li>     <li class="toggle4">four</li>     <li class="toggle5">five</li> </ul>  <div class="container">     <div class="toggle1">here contents of 1..</div>     <div class="toggle2" style="display:none;">here contents of 2..</div>     <div class="toggle3" style="display:none;">here contents of 3...</div>     <div class="toggle4" style="display:none;">here contents of 4....</div>     <div class="toggle5" style="display:none;">here contents of 5.....</div> </div> 

here solution have provided , working. fade in , fade out animation needs delay avoid jerk between sibling elements. in hide , show there no delay in animation looks fine you. edit milliseconds want. default have put 200.

$('.menu>li').on('click',function(e){ var target = $('.container>.'+ e.target.classlist[0]); target.siblings().fadeout(200); target.delay(200).fadein() }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -