什么是.apply jQuery函数? [英] What's the .apply jQuery function?

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

问题描述

我在不同的插件和代码中看到了,但是我不明白该函数是什么...在jQuery api中没有被引用!

I see that in different plugins and codes, but I don't understand what does that function... In the jQuery api isn't referenced!

推荐答案

apply 使用一组参数调用函数。它不是jQuery的一部分,它是核心Javascript的一部分。但是,在jQuery文档中提到它:

apply calls a function with a set of arguments. It's not part of jQuery, it's part of core Javascript. However, there is mention of it in the jQuery docs:

http://docs.jquery.com/Types#Context.2C_Call_and_Apply

语法:

somefunction.apply(thisObj, [argsArray])

以上调用函数 somefunction ,将设置为 thisObj 在函数的作用域内,并传入来自 argsArray 的参数作为函数的参数。

The above calls the function somefunction, setting this to thisObj within the function's scope, and passing in the arguments from argsArray as the arguments to the function.

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

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