(This article reproduced: http://www.cnblogs.com/wyjgreat/archive/2011/07/19/2110754.html)
Jquery provides two methods for development plug-ins:
JavaScript code
jQuery.fn.extend(object); jQuery.extend(object);
Jquery. Extend (object); adds a new method to the class to extend the jquery class itself.
Jquery. FN. Extend (object); add a method to the jquery obj
$. Extend () and $. fn. extend () Functions
$. Extend () and $. fn. extend () functions:The two methods in the title are very important in jQuery plug-in development. The following describes their usage through simple code examples.This topic does not describe how it works. Instead, it only describes what they do and w
Jquery $. FN $. FX
$. FN refers to the namespace of jquery. Adding Methods and attributes on FN will be effective for each jquery instance.For example, extend $. FN. ABC (), that is, $. FN. ABC () is an extension of the ABC method for jquery, so every jquery instance can reference this method later.Then you can: $ ("# Div"). ABC ();Extends are usually used. For more information, see the API.
Jquery provides two methods for development plug-ins:
Jqu
$. Data Applications under $. extend and $. fn,. extend. fn
1. First, we will study $. data
1) code snippet
Note: add the data-name attribute to the tag to call the value of the variable named after data-in $. data.
2) connection code, $. data Usage in $. fn
$. Extend ($. fn ,{
ShowAge: function (){Console. log (this [0]. dataset. age );}});
$ ("# Test"). sho
JQuery provides two methods for development plug-ins:Copy codeThe Code is as follows:JQuery. fn. extend (object );JQuery. extend (object ); JQuery. extend (object); adds a new method to the class to extend the jQuery class itself.JQuery. fn. extend (object); add a method to
People who have extended jQuery or created jQuery plug-ins may be familiar with these two methods. jQuery. extend ([deep], target, object1, object2... [objectN]) jQuery. fn. extend ([deep], target, object1, object2... [objectN]) These two attributes are used to merge the attributes of two or more objects to the target object. deep is a Boolean value, indicating whether to perform deep merge. The default val
Statement: This article is an original article by the author, all of which have been analyzed by the author one by one. I hope you can give me some advice if there is something wrong with it.
You are welcome to reprint it. Please indicate the source for reprinting.
Address: http://imsiren.com/archives/525
I haven't written jquery source code for a long time ..There is a major factor in jquery's development because it is very easy to expand, and the reason is thatExtend FunctionsThis function
Use the list. extend () method in the list of operations in Python, pythonlist. extend
The extend () method appends the sequence content to the list.Syntax
The syntax of the extend () method is as follows:
List. extend (seq)
Parameters
Seq -- this is the list element
Long time no write the content of the jquery source.The development of jquery is a big factor because it is very easy to expand, and the reason is that it benefits from the Extend functionThe function is an extension function ... is an extended function, which is actually a shallow copy and a deep copy function.The function is really powerful, and it's very elegant to write.Take a look at the usage first, there are three ways to use it.
T
In addition to using the $.extend Extension tool function, you can extend the original object, and when Object the object is extended, two objects are merged, and when the same property name exists, the latter overrides the former, and the calling format is:$.extend (obj1,obj2,…objN);The parameters obj1 through OBJN represent the various original objects that nee
JQuery customizes jQuery. extend () and jQuery. fn. extend () method. jQuery. the extend () method can create global functions or selectors, whereas jQuery. fn. the extend () method can create jQuery object methods. the two methods use the same code. One is used to merge attributes and methods for jQuery objects or com
JQuery customizes jQuery. extend () and jQuery. fn. extend () method. jQuery. the extend () method can create global functions or selectors, whereas jQuery. fn. the extend () method can create jQuery object methods. the two methods use the same code. one is used to merge attributes and methods for jQuery objects or com
Implementation of extend in jquery
Generally, when we use the extend of jquery, most of them are used to overwrite the default field. That is, if the value of a field is input, the input value is used; otherwise, the default value is used. The following code:
function getOpt(option){var _default = {name : 'wenzi',age : '25',sex : 'male'}$.extend(_default, option)
ArticleDirectory
Example 1: Expand jquery itself
Example 2: Extended object
Example 3: shallow copy-references exist in OBJ
Example 4: Deep copy-references exist in OBJ
Example 5: Expand jquery. FN
From the jquery source code, we can see that jquery. Extend and jquery. FN. Extend are actually different references pointing to the same method.
Jquery.
Analyzed the implementation principle of the extend method in JQuery
This article mainly introduces how to use jQuery. the source code of extend analyzes the implementation principle and usage of the extend method in JQuery. It is very detailed. We recommend it to you here. If you need it, refer to it.
I haven't posted a post for a long time. Today I suddenly a
jquery's Extend extension method:The extended method of jquery extend is a common method in the process of writing plug-ins, there are some overloaded prototypes, here we go to understand.One, jquery extension method prototype is:
Extend (dest,src1,src2,src3 ...);
It means to src1,src2,src3 ... Merged into Dest, the return value is the merged dest, which show
Since it is a class, there is an abstract class, a specific class, and class inheritance. At the same time, the class members can have instance members and static members. Let's take a look at how prototype achieves this.
First look at the following in prototype
Code :
Copy code The Code is as follows: var abstract = new object ();
Object. Extend = function (destination, source ){
For (property in source ){
Destination [property] = source [property]
Analyzed the implementation principle of the extend method in JQuery, jqueryextend
I haven't posted a post for a long time. Today I suddenly analyzed the implementation principle of the extend method in JQuery. The purpose is to improve your understanding of JQuery and how JavaScript masters compile JavaScript. If you have any questions, please correct me. Thank you!
The following is the source code of the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.