<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='docs-1.7.xsl'?>
<entries><entry type='method' name="offset" return="Object">
    <signature>
      <added>1.2</added>
    </signature>
    <desc>Get the current coordinates of the first element in the set of matched elements, relative to the document.</desc>
    <longdesc><p>The <code>.offset()</code> method allows us to retrieve the current position of an element <em>relative to the document</em>. Contrast this with <code>.position()</code>, which retrieves the current position <em>relative to the offset parent</em>. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), <code>.offset()</code> is the more useful.</p>

    <p><code>.offset()</code> returns an object containing the properties <code>top</code> and <code>left</code>.</p>
<blockquote><p><strong>Note:</strong> jQuery does not support getting the offset coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.</p></blockquote>
    </longdesc>
    <example>
      <desc>Access the offset of the second paragraph:</desc>
      <code><![CDATA[var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );]]></code>
  <css><![CDATA[
p { margin-left:10px; }
  ]]></css>
  <html><![CDATA[<p>Hello</p><p>2nd Paragraph</p>]]></html>
</example>
<example>
  <desc>Click to see the offset.</desc>
  <code><![CDATA[
$("*", document.body).click(function (e) {
  var offset = $(this).offset();
  e.stopPropagation();
  $("#result").text(this.tagName + " coords ( " + offset.left + ", " +
                                  offset.top + " )");
});

]]></code>
  <css><![CDATA[
p { margin-left:10px; color:blue; width:200px;
    cursor:pointer; }
span { color:red; cursor:pointer; }
div.abs { width:50px; height:50px; position:absolute;
          left:220px; top:35px; background-color:green;
          cursor:pointer; }
  ]]></css>
  <html><![CDATA[<div id="result">Click an element.</div>
<p>
  This is the best way to <span>find</span> an offset.
</p>

<div class="abs">
</div>
  ]]></html>
  </example>
<category name="CSS"/>
<category name="Offset"/>
<category name="Style Properties"/>
<category name="Version 1.2"/>
<category name="Version 1.4"/>
</entry><entry type='method' name="offset" return="jQuery">
  <signature>
    <added>1.4</added>
    <argument name="coordinates" type="Object">
      <desc>An object containing the properties <code>top</code> and <code>left</code>, which are integers indicating the new top and left coordinates for the elements.</desc>
    </argument>
  </signature>
  <signature>
    <added>1.4</added>
    <argument name="function(index, coords)" type="Function">
      <desc>A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new <code>top</code> and <code>left</code> properties.</desc>
    </argument>
  </signature>
  <desc>Set the current coordinates of every element in the set of matched elements, relative to the document.</desc>
  <longdesc><p>The <code>.offset()</code> setter method allows us to reposition an element. The element's position is specified <em>relative to the document</em>. If the element's <code>position</code> style property is currently <code>static</code>, it will be set to <code>relative</code> to allow for this repositioning.</p></longdesc>
  <example>
    <desc>Set the offset of the second paragraph:</desc>
    <code><![CDATA[$("p:last").offset({ top: 10, left: 30 });]]></code>
    <css><![CDATA[p { margin-left:10px; } ]]></css>
    <html><![CDATA[<p>Hello</p><p>2nd Paragraph</p>]]></html>
  </example>
<category name="CSS"/>
<category name="Offset"/>
<category name="Style Properties"/>
<category name="Version 1.2"/>
<category name="Version 1.4"/>
</entry></entries>