Solved

Jquery hanling position error

Posted on 2014-01-29
3
212 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Date on a table 16 36
Asp response.write to clients 6 34
Html date format 9 20
Scroll 5 news at a time using vticker 2 11
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…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
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)

726 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