Custom jQuery Selector method does not capture text nodes
<p>I am trying to create a custom jQuery selector that will put focus() on a input text field whose label text is provided by the user.</p>

<p>It is simple, I take the text provided by the user, search for the text node of all labels, get the matching label's 'for' attribute value and use that as an id to get the input element.</p>

<p>My problem is that I am unable to access the text node as the nodes being passed in stack are everything except the text nodes. I checked the child element of the label and it says null in firebug.</p>

<p>Here is what part of the code looks like:</p>

<pre><code>$.expr[':'].findipfromlabel = function(obj, index, meta, stack) {
 if($(obj).find("label").text() == meta[3]) {
  var forattr = $(obj).attr('for');
 }
 return ($(input).attr('id' == forattr));
};

$(document).ready(function() {
 $(': findipfromlabel(Male)').focus();
});
</code></pre>

<p>In above, label elements are present but there is no child element of that label. There is a next sibling, but how to confirm with label to use unless I know the text node value equals what the user has entered?
HTML is:</p>

<pre><code>&lt;form&gt;
  &lt;label for="v"&gt;test&lt;/label&gt;
  &lt;input type="text" name="v" id="v" /&gt;&lt;br/&gt;
  &lt;label for="male"&gt;Male&lt;/label&gt;
  &lt;input type="text" name="m" id="male" /&gt;
  &lt;br /&gt;
  &lt;label for="fe"&gt;Female&lt;/label&gt;
  &lt;input type="text" name="f" id="fe" /&gt;
&lt;/form&gt;
</code></pre>
