Reputation: 4502
I have an slider that ads an class (.current-item) to each tab that is on, and removes when it`s off. I want to use LavaLamp for the menu efect and I need to get the position of the each element that has class current-item.
I used:
var my = $("li.current-item");
var myposition = my.position();
function setCurr(el) {
$back.css({'top': myposition.top });
curr = el;
};
But it works only for one item (the first). Afer the slider removes the class and ads the class to the next li nothing happens.
Here it is live: http://asgg.ro/slider-html/ The src to the script is at the bottom of the source.
I`m new to jquery and I really need some help! Thank you very much
Upvotes: 0
Views: 8074
Reputation: 654
var offset = $('.class_name').offset();
var x_pos = offset.left;
var y_pos = offset.top;
this will give you the X and Y position of the element related to the viewport Hoper this helps
Upvotes: 2
Reputation: 46008
Try
function setCurr(el) {
var my = $("li.current-item");
var myposition = my.position();
$back.css({'top': myposition.top });
curr = el;
};
Upvotes: 1