I need to create a toggle that animates upwards not downwards in other words the reverse of the "normal" toggle. Perhaps simpler is the toggle should slide up above the menu item (it's a menu) to become visible rather than slide down as the normal slideToggle etc. would do. I am nearly there with this :
var opened = false;
$("#coltab li").click(function(){
if(opened){
$(this).children('ul').animate({"top": "+=300px"});
} else {
$(this).children('ul').animate({"top": "-=300px"});
}
$(this).children('ul').children().slideToggle('slow');
$(this).children('ul').toggle();
opened = opened ? false : true;
});
BUT if you "toggle" an item THEN another item the second item (slides down) falls by the 300px NOT slide up (raises) by 300px. A good example (hate the site) of what I want to achieve is http://market.weogeo.com/#/home and the "tabs"at the bottom.
My HTML code is using
<ul id="#coltab">
<li>Item 1
<ul>
<li>This bit needs to toggle up</li>
</ul>
</li>
<li>Item 2
<ul>
<li>This bit needs to toggle up</li>
</ul>
</li>
etc ...
</ul>
On the CSS side
ul#coltab { position: relative' blah; blah; }
and
ul#coltab ul { display: none; position: absolute; blah; blah; }
Any ideas?
It would be nice if each "click" closed the previous toggle before opening the "clicked" toggle.