Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (38 sloc) 1.92 kb
<?xml version="1.0"?>
<entry type="property" name="selector" return="String">
<title>.selector</title>
<signature>
<added>1.3</added>
</signature>
<desc>A selector representing selector originally passed to jQuery().</desc>
<longdesc>
<p>Should be used in conjunction with context to determine the exact query used.</p>
<p>The <code>.live()</code> method for binding event handlers uses this property to determine how to perform its searches. Plug-ins which perform similar tasks may also find the property useful. This property contains a string representing the matched set of elements, but if DOM traversal methods have been called on the object, the string may not be a valid jQuery selector expression. For this reason, the value of <code>.selector</code> is generally most useful immediately following the original creation of the object. Consequently, the <code>.live()</code> method should only be used in this scenario. </p>
</longdesc>
<example>
<desc>Determine the selector used.</desc>
<code><![CDATA[$("ul")
.append("<li>" + $("ul").selector + "</li>")
.append("<li>" + $("ul li").selector + "</li>")
.append("<li>" + $("div#foo ul:not([class])").selector + "</li>");
]]></code>
<css><![CDATA[
body { cursor:pointer; }
div { width:50px; height:30px; margin:5px; float:left;
background:green; }
span { color:red; }
]]></css>
<html><![CDATA[Some selectors:<ul></ul>]]></html>
</example>
<example>
<desc>Collecting elements differently</desc>
<code><![CDATA[
$('<div>' + $('ul li.foo').selector + '</div>').appendTo('body'); // "ul li.foo"
$('<div>' + $('ul').find('li').filter('.foo').selector + '</div>').appendTo('body'); // "ul li.filter(.foo)"
]]></code>
<html><![CDATA[Some selectors:<ul></ul>
]]></html>
</example>
<category slug="internals"/>
<category slug="properties/global-jquery-object-properties"/>
</entry>
Jump to Line
Something went wrong with that request. Please try again.