Are these three equivalent?
$(function(){
$("#a").html("i am a")
});
(function($){
$("#b").html("i am b")
})($);
(function(){
$("#c").html("i am c")
})();
Reference:
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first one actually waits for the ready event, while the others do not.
The second one is used for aliasing JQuery, but is useless in the way it is used now. You pass
$, which is received in the parameter$. This construct is usually used when another library is used that assigns a different value to$. In that case you can callfunction($){...}(jQuery), to still have the$variable pointing to jQuery in the scope of the function.