How can it be that this doesn’t alert 0 (instead, it alerts 50)?
I need the td position relative to the table
HTML:
<div style="height:40px"></div>
<div>
<table id="tbl">
<tr>
<td id="td1">linje 1</td>
</tr>
<tr>
<td id="td2">linje 2</td>
</tr>
</table>
</div>
JS:
var elm = $('#td1');
var position = elm.position();
alert(position.top);
edit:
I need the tr position relative to the table 🙂
Add
position: relative;to the table. Doing that will make it alert 0. Otherwise, it’s finding position relative to the document.