JQuery-PAge load
Upon page reload, all the nodes expand and then only the selected node remain expanded which is the desired behavior. However, I'd like to prevent all the nodes from expanding up开发者_C百科on refresh as it creates a flicker. Has anyone else experience this behaviour? How can I turn it off?
Thanks
Instead of showing then hiding, hide then show.
If possible you should hide them from the start using CSS better than Javascript. If you can't (depending on your app fonctionnality or else), you can hide every item at page load and just expand the one you want. The rendering will be better I guess.
quick & dirty example:
http://jsbin.com/iyika3/edit
$(document).ready(function(){
$('ul > li').toggle(function(){
$(this).find('ul').slideDown('fast');
}, function(){
$(this).find('ul').slideUp('fast');
});
});
精彩评论