.is() doesn't support "complex" selectors (in this case the descendant
selector).  Unfortunately, this is undocumented and very misleading.
There are two potential solutions:
1) .is'('.exit') && .parents('#nav').length
2) override .is() to work as intended (below is the code I'm currently
using)


jQuery.fn.is = function( selector ) {
        if ( !selector ) return false;

        if ( !/[\s>]/.test( selector ) ) {
                return jQuery.multiFilter( selector, this ).length > 0;
        }

        var ret = false;
        var els = jQuery( selector ).get();
        jQuery.each(this, function(){
                if ( jQuery.inArray( this, els ) != -1 ) {
                        ret = true;
                        return false;
                }
        });
        return ret;
};

On Feb 20, 1:10 pm, hartshorne <[EMAIL PROTECTED]> wrote:
> Hi, I'm new to jQuery, and found something unexpected. With something
> like this:
>
> <div id="nav">
>     <a href="/exit/" class="exit">Exit</a>
>     <a href="/open/" class="open">Open</a>
> </div>
> <script type="text/javascript" charset="utf-8">
> jQuery('#nav').bind('click', function() {
>     alert(jQuery(event.target).is('#nav .exit'));
>     event.preventDefault();});
>
> </script>
>
> I expect .is('#nav .exit') to return true when the event is fired from
> the Exit link, and false otherwise. Instead it always returns true.
> What am I missing?
>
> Thanks!

Reply via email to