I noticed in the jQuery docs that as of 1.4, calling $() with no args just returns an empty set rather than $(document). http://api.jquery.com/jQuery/#returning-empty-set
So, is there no other shorthand for $(document)?
I ask because I 开发者_C百科can't decide which is uglier if I'm trying to select an element by an ID that I have in a variable: $("#" + myID) or $(document).find(myId).
Thanks.
You always can make your own alias:
$d = $(document);
If you are selecting an element by an ID you should use $("#" + myID)
. $(document).find(myId)
would be wrong.
精彩评论