<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='docs-1.7.xsl'?>
<entries><entry type='selector'  name="text" return="" >
                <sample>:text</sample>
                 <signature><added>1.0</added> </signature>
                <desc>Selects all elements of type text.</desc>
                <longdesc><p><code>$(':text')</code> is equivalent to <code>$('[type=text]')</code> and thus selects all <code>&lt;input type="text"&gt;</code> elements. As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare <code>$(':text')</code> is equivalent to <code>$('*:text')</code>, so <code>$('input:text')</code> should be used instead. </p>
<p><strong>Note:</strong> As of jQuery 1.5.2, <code>:text</code> selects <code>input</code> elements that have no specified <code>type</code> attribute (in which case <code>type="text"</code> is implied).  </p>
</longdesc>
                <example>
                    <desc>Finds all text inputs.</desc>
                    <code><![CDATA[

    var input = $("form input:text").css({background:"yellow", border:"3px red solid"});
    $("div").text("For this type jQuery found " + input.length + ".")
            .css("color", "red");
    $("form").submit(function () { return false; }); // so it won't submit

]]></code>
                    <css><![CDATA[
  textarea { height:25px; }
  ]]></css>
                    <html><![CDATA[<form>
    <input type="button" value="Input Button"/>
    <input type="checkbox" />

    <input type="file" />
    <input type="hidden" />
    <input type="image" />

    <input type="password" />
    <input type="radio" />
    <input type="reset" />

    <input type="submit" />
    <input type="text" />
    <select><option>Option</option></select>

    <textarea></textarea>
    <button>Button</button>
  </form>
  <div>
  </div>]]></html>
                </example>
            <category name="Form"/>
<category name="jQuery Extensions"/>
<category name="Version 1.0"/>
<note type="additional">Because <code>:text</code> is a jQuery extension and not part of the CSS specification, queries using <code>:text</code> cannot take advantage of the performance boost provided by the native DOM <code>querySelectorAll()</code> method. For better performance in modern browsers, use <code>[type="text"]</code> instead.</note></entry><entry type='method' name="text" return="String">
    <signature>
      <added>1.0</added>
    </signature>
    <desc>Get the combined text contents of each element in the set of matched elements, including their descendants.</desc>
    <longdesc><p>Unlike the <code>.html()</code> method, <code>.text()</code> can be used in both XML and HTML documents. The result of the <code>.text()</code> method is a string containing the combined text of all matched elements. (Due to variations in the HTML parsers in different browsers, the text returned may vary in newlines and other white space.) Consider the following HTML:</p>
<pre>&lt;div class="demo-container"&gt;
  &lt;div class="demo-box"&gt;Demonstration Box&lt;/div&gt;
  &lt;ul&gt;
  &lt;li&gt;list item 1&lt;/li&gt;
  &lt;li&gt;list &lt;strong&gt;item&lt;/strong&gt; 2&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
</pre>
      <p>The code <code>$('div.demo-container').text()</code> would produce the following result:</p>
      <p>
        <code>Demonstration Box list item 1 list item 2</code>
      </p>
      <p>The <code>.text()</code> method cannot be used on form inputs or scripts.  To set or get the text value of <code>input</code> or <code>textarea</code> elements, use the <a href="/val"><code>.val()</code></a> method. To get the value of a script element, use the <a href="/html"><code>.html()</code></a> method.</p>
      <p>As of jQuery 1.4, the <code>.text()</code> method returns the value of text and CDATA nodes as well as element nodes.</p>
    </longdesc>
    <example>
      <desc>Find the text in the first paragraph (stripping out the html), then set the html of the last paragraph to show it is just text (the red bold is gone).</desc>
      <code><![CDATA[
    var str = $("p:first").text();
    $("p:last").html(str);
]]></code>
<css><![CDATA[
  p { color:blue; margin:8px; }
  b { color:red; }
  ]]></css>
  <html><![CDATA[<p><b>Test</b> Paragraph.</p>

  <p></p>]]></html>
  </example>
<category name="DOM Insertion, Inside"/>
<category name="Version 1.0"/>
<category name="Version 1.4"/>
</entry><entry type='method' name="text" return="jQuery">
  <signature>
    <added>1.0</added>
    <argument name="textString" type="String">
      <desc>A string of text to set as the content of each matched element.</desc>
    </argument>
  </signature>
  <signature>
    <added>1.4</added>
    <argument name="function(index, text)" type="Function">
      <desc>A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.</desc>
    </argument>
  </signature>

  <desc>Set the content of each element in the set of matched elements to the specified text.</desc>
  <longdesc><p>Unlike the <code>.html()</code> method, <code>.text()</code> can be used in both XML and HTML documents. </p>
  <p>We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method <code>.createTextNode()</code>, which replaces special characters with their HTML entity equivalents (such as <code>&amp;lt;</code> for <code>&lt;</code>).  Consider the following HTML:</p>
				<pre>&lt;div class="demo-container"&gt;
  &lt;div class="demo-box"&gt;Demonstration Box&lt;/div&gt;
  &lt;ul&gt;
    &lt;li&gt;list item 1&lt;/li&gt;
    &lt;li&gt;list &lt;strong&gt;item&lt;/strong&gt; 2&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
</pre>
	<p>The code <code>$('div.demo-container').text('&lt;p&gt;This is a test.&lt;/p&gt;');</code> will produce the following DOM output:</p>
	<pre>&lt;div class="demo-container"&gt;
&amp;lt;p&amp;gt;This is a test.&amp;lt;/p&amp;gt;
&lt;/div&gt;</pre>
	<p>It will appear on a rendered page as though the tags were exposed, like this:</p>
	<pre>&lt;p&gt;This is a test&lt;/p&gt;</pre>
	<p>The <code>.text()</code> method cannot be used on input elements.  For input field text, use the <a href="/val">.val()</a> method.</p>
  <p>As of jQuery 1.4, the <code>.text()</code> method allows us to set the text content by passing in a function.</p>
<pre>$('ul li').text(function(index) {
  return 'item number ' + (index + 1);
});</pre>
  <p>Given an unordered list with three <code>&lt;li&gt;</code> elements, this example will produce the following DOM output:</p>
<pre>&lt;ul&gt;
  &lt;li&gt;item number 1&lt;/li&gt;
  &lt;li&gt;item number 2&lt;/li&gt;
  &lt;li&gt;item number 3&lt;/li&gt;
&lt;/ul&gt;
</pre>
</longdesc>
                <example>
                    <desc>Add text to the paragraph (notice the bold tag is escaped).</desc>
                    <code><![CDATA[$("p").text("<b>Some</b> new text.");]]></code>
                    <css><![CDATA[

  p { color:blue; margin:8px; }
  ]]></css>
                    <html><![CDATA[<p>Test Paragraph.</p>]]></html>
                </example>
            <category name="DOM Insertion, Inside"/>
<category name="Version 1.0"/>
<category name="Version 1.4"/>
</entry></entries>