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/
精彩评论