Bug Tracker

Opened 10 years ago

Closed 9 years ago

#6043 closed bug (worksforme)

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?

Change History (1)

comment:1 Changed 9 years ago by addyosmani

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.

Note: See TracTickets for help on using tickets.