您可以通过提供ul标记使标记成为li偏移父项position: relative.这将允许你打电话position的li,它会告诉你,你想知道什么.
var pos = $("#target").position();
$("#target").text("This li is positioned " + pos.top
+ "px from the top and " + pos.left
+ "px from the left edge of the ul");
Run Code Online (Sandbox Code Playgroud)