• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get and set the position of an element in Java Script

 
sandeep Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I want the functionality of getting the position of an element and also setting the postion of an element in Java Script. If any body has some working code snippetts, Please help me.

Thanks in Advance.


Regards,
Sandeep.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To position:
Well you have CSS with position absolute or relative with top and left. You also have margins and padding to move it.

To read position:

Either you can read the CSS if it is positioned absolutely.

If not you have to do something like this:



You would call it:



Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if this is really important, then I recommend you check out jQuery and its Dimensions plugin which will take care of all these calculations for you.
 
sandeep Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric Pascarello and Bear Bibeault,

Thanks for your valuable suggestions.

Regards,
Sandeep.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic