Bug Tracker

Modify

Ticket #6043 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by addyosmani

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to worksforme

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.