Determine relative left position for a table cell

27 views
Skip to first unread message

kstubs

unread,
Feb 1, 2012, 12:11:54 AM2/1/12
to prototype-s...@googlegroups.com
I'm getting a little hung up determining the relative left position for a table cell.  I need to know the left offset value according to its container, either the table itself or the table's container.
So which method is preferred?

Thanks.
Karl..

goldenmean

unread,
Feb 2, 2012, 1:35:43 PM2/2/12
to Prototype & script.aculo.us
Do you mean to say that you need to know how many pixels the left edge
of the table cell is from the left edge of the table itself?

Try this example:

<table id="container">
<tr><td>X</td><td id="cell">Y</td><td>Z</td></tr>
</table>

var someOffset = $('cell').relativeTo($('container'));

var someLeft = someOffset.left;
Reply all
Reply to author
Forward
0 new messages