Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Understanding getting positions in Javascript
Old 04-03-2007, 12:57 PM Understanding getting positions in Javascript
Super Talker

Posts: 116
Trades: 0
Hey there,

I'm trying to understand how to get the position of elements on the page... basically, how to find the position of a parent and then lining up the child to that parent.

I searched for hours on the web about offsetLeft and offsetParent... but it's not making sense.

I used this in an example for menus on the www.musiciansatlas.com website to get those submenus with less than three to line up under their parent menu.

But I have no clue what I did.

For Mozilla/Safari, I did:

Subnav5.style.left = Subnav5.offsetParent;

It works (don't ask me how), but is that the right syntax?

Donna
DonnaZ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-03-2007, 01:18 PM Re: Understanding getting positions in Javascript
Super Talker

Posts: 116
Trades: 0
It's DZ again... I just wanted to be clear on the above.

the Subnav5.style.left is based on getting the ID of the sub-navigation menu. This sub-nav menu is the child of a list element in the master navigation menu. Thus it's
<div id="navigation>
<ul>
<li>Navigation Item 1</li>
<ul id = "Subnav5">
<li Subnav Item 1</li>
</ul>
</ul>
</div>

I'm just trying to see if I'm right in understanding that by using offsetParent, it's getting the <li Navigation Item 1> and not the <div id="navigation">.

I inherited this menu and changed the JavaScript because my bosses wanted those menu items with less than three to line up not on the left, but under the submenu.

It worked by doing the... Subnav5.style.left = Subnav5.offsetParent;
But is this correct logic?

I get really frustrated when I can't understand something.
DonnaZ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Understanding getting positions in Javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10090 seconds with 12 queries