forked from jquery/api.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext.xml
31 lines (30 loc) · 1.58 KB
/
context.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?xml version="1.0"?>
<entry type="property" name="context" return="Element">
<title>.context</title>
<signature>
<added>1.3</added>
</signature>
<desc>The DOM node context originally passed to <code>jQuery()</code>; if none was passed then context will likely be the document.</desc>
<longdesc>
<p>The <code>.live()</code> method for binding event handlers uses this property to determine the root element to use for its event delegation needs.</p>
<p>The value of this property is typically equal to <code>document</code>, as this is the default context for jQuery objects if none is supplied. The context may differ if, for example, the object was created by searching within an <code><iframe></code> or XML document.</p>
<p>Note that the context property may only apply to the elements originally selected by <code>jQuery()</code>, as it is possible for the user to add elements to the collection via methods such as <code>.add()</code> and these may have a different context.</p>
</longdesc>
<example>
<desc>Determine the exact context used.</desc>
<code><![CDATA[$("ul")
.append("<li>" + $("ul").context + "</li>")
.append("<li>" + $("ul", document.body).context.nodeName + "</li>");
]]></code>
<css><![CDATA[
body { cursor:pointer; }
div { width:50px; height:30px; margin:5px; float:left;
background:green; }
span { color:red; }
]]></css>
<html><![CDATA[Context:<ul></ul>]]></html>
</example>
<category slug="internals"/>
<category slug="properties/jquery-object-instance-properties"/>
<category slug="version/1.3"/>
</entry>