Skip to main content

Bug Tracker

Side navigation

#6043 closed bug (worksforme)

Opened February 06, 2010 05:02AM UTC

Closed October 22, 2010 08:35PM UTC

jquery 1.4 with compact-1.3 have some issue about multi-selector

Reported by: hinablue Owned by:
Priority: undecided Milestone: 1.4.2
Component: selector Version: 1.4.1
Keywords: multi-selector Cc:
Blocked by: Blocking:
Description

When I used the jquery 1.4 and jquery-compact-1.3 (http://github.com/jquery/jquery-compat-1.3). I found:

$('#div-a, #div-b').click(function() { alert('foo'); }

The multi-selector cannot work correctly.

I check the jquery-compact-1.3, line 125-138,

// jQuery() now returns an empty jQuery set, not jQuery(document)

var oldinit = jQuery.fn.init;

jQuery.fn.init = function( selector ) {

if ( selector === undefined ) {

return jQuery( document );

}

oldinit.apply( this, arguments );

return this;

};

jQuery.fn.init.prototype = oldinit.prototype;

There is the reason why multi-selector cannot work, but I have no idea how to fix it?

Attachments (0)
Change History (1)

Changed October 22, 2010 08:35PM UTC by addyosmani comment:1

priority: → undecided
resolution: → worksforme
status: newclosed

The reason why your original code wasn't executing correctly is that you forgot to add in the final ')' at the very end of your code. Here's a live test case http://jsfiddle.net/addyosmani/ZkfBk/ where you can see this working fine with jQuery 1.4.3. It also works fine with 1.4.2, 1.3.2 and 1.2.6.