jQuery - Miscellaneous

jquery

What is the purpose of the offsetParent() method?

Returns the offset parent of the first element in the wrapped set. This is the closest ancestor with the position value of relative or absolute, or the body element if no such ancestor is found. This method should be applied only to visible elements.

What is the purpose of the position() method?

The position() method returns an object with two properties (top and left) containing the position values of the first element in wrapped set relative to its offset parent.

What is the purpose and signature of the offset() method?

Returns the offset information for the first element in the wrapped set. By default, this information is relative to the body element, and the manner in which it's calculated is controlled by the settings in the options parameters.

offset(options, results)
  1. options:
    1. relativeTo: (Element). Specifies the ancestor element of the wrapped element to base the relative offset on. This element should have the position value of relative or absolute. If omitted, the default is the body element.
    2. lite: (Boolean). Specifies that certain browser-specific optimization will be skipped. This will increase performance at the price of accuracy. Default is false.
    3. scroll: (Boolean). Specifies whether scroll offsets should be taken into account. Default is true.
    4. padding: (Boolean). Specifies whether padding should be included in the calculation. Default is false.
    5. border: (Boolean). Specifies whether borders should be included in the calculation. Default is false.
    6. margin: (Boolean). Specifies whether margins should be included in the calculation. Default is true.
  2. results: (Object). An optional object to receive the results of the method. If omitted, a new object is created, populated with the results and returned as the value of the method. If specified, the passed object will be augmented with the result, and the wrapped set is returned from the method. This is useful for chaining.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License