Home > Web Front-end > JS Tutorial > body text

(function($){...})(jQuery) means_jquery

WBOY
Release: 2016-05-16 18:22:46
Original
1024 people have browsed it

This is actually an anonymous function

function(arg){...}
This defines an anonymous function with the parameter arg

and when calling the function, it is after the function When writing parentheses and actual parameters, due to the priority of the operator, the function itself also needs parentheses, that is:
(function(arg){...})(param)
This is equivalent to the definition An anonymous function with arg as a parameter, and use param as a parameter to call this anonymous function

and (function($){...})(jQuery) is the same, the reason why it is only in the formal parameter $ is used to avoid conflict with other libraries, so the actual parameters are the same as jQuery
var fn = function($){....};
fn(jQuery);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!