1.) DoSomethingLocal is defined as $.fn.DoSomethingLocal. You can add as many custom functions to the jQuery.fn (or simply $.fn) object as required by your plugin implementation. Any function you add to the $.fn object is assumed to work on references to an instance of an element/object that was selected. This is what the $.fn syntax means - we are simply adding a custom interface to a jQuery object that assumes selected elements.
2.) DoSomethingGlobal is applied directly to the global jQuery object as $.DoSomethingGlobal. A function attached to the jQuery framework in such way assumes that it will not work on selected elements but rather it will work in the global scope and contain practically any implementation.
AJAX 学习笔记--patter
最新推荐文章于 2023-09-27 22:01:52 发布
本文介绍了jQuery中两种方法的应用:一种是本地方法DoSomethingLocal,它作为$.fn.DoSomethingLocal定义,可以为jQuery对象添加自定义接口;另一种是全局方法DoSomethingGlobal,直接附加到$.DoSomethingGlobal,适用于全局范围的操作。
377

被折叠的 条评论
为什么被折叠?



