开发者

How can I get the div information via js?

For example, I have div named $(".aDiv"), how can I get the $(".aDiv") position, and the inform开发者_StackOverflowation about $(".Div") using js? thank you.


It depends what information you're after. For the position for example, there's .position() (relative to the offset parent) and .offset() (relative to the document), like this:

var topCornerFromDocument = $(".aDiv").offset().top;
//or...
var leftCornerFromDocument = $(".aDiv").offset().left;

For other information there are many functions it depends what you're after - .attr() for attributes, .css() for style properties, etc.


http://api.jquery.com/position/

http://api.jquery.com/offset/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜