N00b here. Apologies in advance if this is a bad question.
What’s the difference, in effect, between these two jQuery declarations, if any?
$(document).ready(function(){
alert("I'm so loaded 1.");
});
and
$('document').ready(function(){
alert("I'm so loaded 2.");
});
On a related note, why does this work …
$(document).on('ready',function() {
alert("I'm so loaded 3.");
});
… but this doesn’t?
$('document').on('ready',function() {
alert("I'm so loaded 4.");
});
The
.readymethod ignores the passed in selector because the only valid object it can be called on is the document. It isn’t recommended to use.onor.bindwith thereadyevent. Also, you should never use'document'becausedocumentis always available to you directly.