• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Jquery hanling position error

Hello experts
I 'm trying to use the position of one div so that i can add a new div in an absolute position using the left and top values of the first one
My code:
var position = $('#' + nextdiv).position();
left1 = position.left;alert(left1);
left2 = 186;
left = left1 + left2 ;alert(left);
top1 = position.top;alert(top1);
top2 = 10;
top = top1 + top2; alert(top);

left1 alert is 0 , that is ok
left alert is 186 , that is ok too
top1 alert is 50
but top alert is [object window]  instead of 60
Any help?
0
Panos
Asked:
Panos
  • 2
1 Solution
 
Chris StanyonCommented:
You can't use 'top' as a variable name. Change it to something else:

topTotal = top1 + top2;
alert(topTotal);

Open in new window

0
 
PanosAuthor Commented:
Thank you Chris Stanyon
It solved the problem
0
 
PanosAuthor Commented:
Thank you
regards panos
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now