views:

40

answers:

1

Hi, i have the following piece of HTML code on my page:

<tr>
  <td>
    <div>
      <input type="hidden" name="test" value="">
      <input autocomplete="off" class="ffb-input watermark">
      <div class="ffb">
        <div class="content">
        </div>
      </div>
    </div>
  </td>
</tr>

In JavaScript I get the <tr> element using jquery and trying to search for input like this:

tr.find('div input:hidden')

but nothing is returned. When I'm using find like this:

tr.find('div input[type=hidden]')

Everything is working fine. What is the reason for such behavor? I observe this only in FireFox 3.5.9, not in 3.6.3, Jquery 1.4.2

A: 

The type attribute does not seem to be taken into account for the :hidden selector. As noted in the comments, it should be, so you might want to file a bug.

This seems to be the code for :hidden:

if ( jQuery.expr && jQuery.expr.filters ) {
    jQuery.expr.filters.hidden = function( elem ) {
        var width = elem.offsetWidth, height = elem.offsetHeight,
            skip = elem.nodeName.toLowerCase() === "tr";

        return width === 0 && height === 0 && !skip ?
            true :
            width > 0 && height > 0 && !skip ?
                false :
                jQuery.curCSS(elem, "display") === "none";
    };

    jQuery.expr.filters.visible = function( elem ) {
        return !jQuery.expr.filters.hidden( elem );
    };
}

I don't see anything obviously wrong, but you can try to debug this code and submit a patch, perhaps ..

Matt
But why is it working in FF 3.6.3, Chrome and IE?
dragoon
Actually, it *does* match `input type="hidden"` - http://api.jquery.com/hidden-selector
BoltClock
@dragoon - Sorry, didn't notice that detail. You might want to file a bug.
Matt