Thursday, 5 September 2013

Get the offset of a span's startpoint using jQuery

Get the offset of a span's startpoint using jQuery

I'd like to find the exact start point of a span. However, when I use
jQuery offset or jQuery position, all I get is the starting point of the
span's bounding box, which is not very helpful. Illustration of the
problem available here:
http://jsfiddle.net/V6Gx6/13/
$('div').append('</br>'+$('span').outerHeight(true));
$('div').append('</br>'+$('span').offset().top);
$('div').append('</br>'+$('span').offset().left);
The "left" portion of the span's starting point should not be zero, since
the span does not start at the beginning of the line. Does anyone have a
clever way of circumventing this issue?

No comments:

Post a Comment