Skip to content


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">
<desc>A selector representing selector originally passed to jQuery().</desc>
<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>
<desc>Determine the selector used.</desc>
.append("<li>" + $("ul").selector + "</li>")
.append("<li>" + $("ul li").selector + "</li>")
.append("<li>" + $("div#foo ul:not([class])").selector + "</li>");
body { cursor:pointer; }
div { width:50px; height:30px; margin:5px; float:left;
background:green; }
span { color:red; }
<html><![CDATA[Some selectors:<ul></ul>]]></html>
<desc>Collecting elements differently</desc>
$('<div>' + $('ul').selector + '</div>').appendTo('body'); // "ul"
$('<div>' + $('ul').find('li').filter('.foo').selector + '</div>').appendTo('body'); // "ul li.filter(.foo)"
<html><![CDATA[Some selectors:<ul></ul>
<category slug="internals"/>
<category slug="properties/global-jquery-object-properties"/>
Jump to Line
Something went wrong with that request. Please try again.