You can easily just replace your lines:
list_items[index].style.display = 'block'; list_items[index].style.display = 'none';
with jQuery show() and hide() functions:
$(list_items[index]).show("slow"); $(list_items[index]).hide("slow");
As shown in my updated version of Fiddle
For different transitions, you can use the animate() function, which allows you to tell which css properties are affected. In addition to numeric values, jQuery also supports the special values ββof 'show' , 'hide' and 'toggle' (which, by the way, will show, hide or switch the show / hide status of an element using this property). For example, if you want to compress them only horizontally and leave the vertical alone, you can change the calls to .show() and .hide() to:
$(list_items[index]).animate({width:'show'}, 600); $(list_items[index]).animate({width:'hide'}, 600);
I demonstrated this in another updated Fiddle
Steve k
source share