Reputation: 13
Im facing some problems what i cannot solve for days now.
I wish to get the Position of an element which is have a uniqe ID
Code:
function e_div_show(sid,ctd)
{
var b_fos="t"+sid;
var pos = $(b_fos).offset();
alert(pos.top + ' ' + pos.left);
}
HTML Code:
<?php
...
echo ('<td ID="t'.$array['S_ID'].'">...</td>
...
?>
this is not working..
if i replace the ID to "b_fos" and i comment out the //var b_fos="t"+sid; it working fine.. however in this case the TD ID wont be unique becouse of the php array which generating the code.
Any help please how to define the pos correclty with a javascript variable?
Upvotes: 1
Views: 2471
Reputation: 35973
Try this code you have miss '#' before
function e_div_show(sid,ctd)
{
var b_fos="#t"+sid;
var pos = $(b_fos).offset();
alert(pos.top + ' ' + pos.left);
}
Upvotes: 1
Reputation: 272126
Try changing:
var b_fos = "t" + sid;
To
var b_fos = "#t" + sid;
Upvotes: 4