Solved

Jquery hanling position error

Posted on 2014-01-29
3
210 Views
Last Modified: 2014-01-29
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
Comment
Question by:Panos
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39817760
You can't use 'top' as a variable name. Change it to something else:

topTotal = top1 + top2;
alert(topTotal);

Open in new window

0
 
LVL 2

Author Comment

by:Panos
ID: 39817777
Thank you Chris Stanyon
It solved the problem
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 39817779
Thank you
regards panos
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question