?
Solved

Jquery hanling position error

Posted on 2014-01-29
3
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 2000 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

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

764 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