这个jquery函数意味着什么? [英] What does this jquery function mean?

查看:92
本文介绍了这个jquery函数意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解js库的工作原理,更具体地说是 http://toopay.github。 io / bootstrap-markdown /

I am trying to understand how a js library works, more specifically http://toopay.github.io/bootstrap-markdown/.

整个js文件包含在这个函数中:

The whole js file is wrapped in this function:

!function ($) {
}(window.jQuery);

这是做什么的,以及如何从库外再次调用它?

What does this do and how would I be able to call it again from outside the library?

推荐答案

它创建一个函数然后立即调用它。它之所以如此,所以它所做的所有变量都不是全局变量,因为它们将在函数内部。 只是为了避免在与其他脚本连接时造成问题并节省空间。

It creates a function then immediately calls it. The reason it does that is just so all the variables it makes won't be global, as they'll be inside the function instead. The ! is just to avoid causing problems when it's concatenated with other scripts and to save space.

您不能自己调用​​它,也不能自己调用​​。

You can't call it yourself, nor should you.

这篇关于这个jquery函数意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆