开发者

Getting the left property of an LI element in jQuery?

I have a dynamic list of LI's inside of a UL.

I am trying to somehow be able to 'track' the last LI of the UL which has a class of Last.

I thought if I could test for the left property of the actual LI against some number, say -500, then I could do what I need to do.

The issue is I 开发者_StackOverflow社区can't seem to get that property.

Is this even possible or does the parent (UL in this case) override that?


If you want the left position relative to the page, you could do this:

var left = $('ul li.Last').offset().left;

Or relative to its parent, do this:

var left = $('ul li.Last').position().left;
  • http://api.jquery.com/offset/
  • http://api.jquery.com/position/

Example: http://jsfiddle.net/7Ztns/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜