Is element before or after another element in DOM
<p>Is there a means of detecting whether an element appears before or after another element in markup? This is <em>regardless</em> of position in DOM. It could be a child, a sibling, a parent or a parent's parent. This is a general question, so no markup to share.</p>

<p>To clarify - this is in regards to the element's position in markup, not its display position. Now that I think about it my question is a bit strange because if you have element X and element Y then you can have these scenarios.</p>

<pre><code>//in regards to y
&lt;x /&gt;
&lt;y /&gt; //:after

&lt;y /&gt; //:before
&lt;x /&gt;

&lt;x&gt;&lt;y /&gt;&lt;/x&gt; //not really before or after is it?
</code></pre>
