Skip to main content

Bug Tracker

Side navigation

#5772 closed bug (fixed)

Opened January 08, 2010 10:53AM UTC

Closed July 28, 2010 03:08AM UTC

$() is jQuery but nut $(document) any more?

Reported by: Jessige Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.4a2
Keywords: document Cc:
Blocked by: Blocking:

The line 37~38 of jquery-1.3.2.js:


// Make sure that a selection was provided

selector = selector || document;


It means that $() is equal to $(document), that is very helpful. But when I updated the JQuery lib form 1.3.2 to 1.4a2, my application could not work any more.

The line 70~73 of jquery-1.4a2.js:


// Handle $(""), $(null), or $(undefined)

if ( !selector ) {

return this;



Then what is $(), an empty jQuery object?

Maybe it will be better if:


if ( selector === undefined ) {

selector = document;


else if ( !selector ) {

return this;



BTW, some spaces are lost between ")" and "{", and some ";" are lost after "}" etc.

Attachments (0)
Change History (4)

Changed January 08, 2010 10:56AM UTC by Jessige comment:1

I always use $() like this

$().keypress(function(event) {

do something here


Changed January 08, 2010 02:22PM UTC by dmethvin comment:2


is now an empty jQuery set in 1.4. The release notes will call it out so people can change their code before upgrading. I think it's the natural interpretation but agree it's a breaking change. Create a thread in jQuery-dev if you feel like it's too breaking. :)

Changed January 11, 2010 03:19AM UTC by Jessige comment:3

Allll right, I do not know witch is better, but I like $() === $(document) still. :)

Changed July 28, 2010 03:08AM UTC by dmethvin comment:4

resolution: → fixed
status: newclosed