I am trying to implement a vertical accordion menu in jQuery with a little diffence. I want to animate an arrow at the left side of the main menus and an arrow at the right side of the sub menus.
I may not visualize it but my problem is simple. When an element clicked, i need to get its top position but its position changed after I clicked the element because its sub menu is shrinking or augmenting.
How can I get the latest position of that element after its submenu is animated and change its position?
You can find the code below. It may explain itself..
$("#firstpane p.menu_head").click(function(e)
{
$('#larrow').hide();
$(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
$('#bgImageContainer').show();
$('.slidesContainer').hide();
$('.slidesThumbs').hide();
if($(this).hasClass('subcategory')){
animateLeftArrow(this);
}
});
function animateLeftArrow(item){
var pos = $('#rarrow').css('top').replace(/[^-\d\.]/g, '');
var itpos = $(item).position();
if($(item).hasClass("first"))
lastpos = itpos.top -202 + 9;
else
lastpos = itpos.top - 202;
$('#rarrow').show();
$('#rarrow').animate({
top: lastpos
});
}