2

Possible Duplicate:
Left offset of an inline element using jQuery

I have this HTML:

<div>hello <span>world<br/>
hello world</span></div>

Obviously, the span element starts not at the beginning in the first line and thus its shape is not exactly rectangular. However, if I use jQuery to get the position

$("div").offset().left === $("span").offset().left // is true

How can I determine the actual left-corner of the span?

Community
  • 1
  • 1
orion3
  • 9,797
  • 14
  • 67
  • 93
  • What do you mean by `actual left corner position`? – Derek 朕會功夫 Jun 17 '12 at 03:57
  • I mean that if you set a background for this span, you'll see the background starts not at the beginning of the line, but with the word "hello". I basically want the position at which this word starts, whereas `offset().left` fot the span returns the beginning of the line position. – orion3 Jun 17 '12 at 03:59
  • Yes, it's a duplicate. Thanks, this solves my problem. – orion3 Jun 17 '12 at 04:00

0 Answers0