selector.
Back to the top of the page
Using Plug-ins to extend JQuery
Unlike most software, using a complex API to write Plug-ins for jQuery is not very difficult. In fact, the JQuery plug-in is very easy to write, and you
("300"); // set the height of the element whose id is msg to 300$ ("# Msg"). width (); // return the width of the element whose id is msg$ ("# Msg"). width ("300"); // set the width of the element whose id is msg to 300
$ ("Input"). val ("); // return the value of the input box of the form.$ ("Input"). val ("test"); // set the value of the form input box to test
$ ("# Msg"). click (); // trigger the click event of an element whose id is msg$ ("# Msg"). click (
jquery's Tool method, in fact, is static method, the source code is through the Extend method, these tools are added to the jquery constructor.Jquery.extend ({......Guid:1, Unique identifier, which is related to the event. For example: function Show () {alert (this);}, $ ("#input1"). Click (Show), $ ("#input2"). Click (function () {$ ("#input1"). Off ()}), The Show method here is the event method, so it is easy to find the event method show by cancel
(expression, [context])-$ (expression, [context]); by default, $ () queries the DOM elements in the current HTML document.
Each (callback) executes a function using each matching element as the context.
Example: 1
$ ("Span"). click (function ){
$ ("Li"). each (function (){
$ (This). toggleClass ("example ");
});
});
Example: 2
$ ("Button"). click (function (){
$ ("P"). each (function (index, domEle ){
// DomEle = this
((Domele).css ("backgroundColor", "yellow ");
If ($ (this). is ("# stop ")){
through $.fn
Created using the part factory method of the jquery UI by $.widget ()
Usually we use the second method for simple plug-in development, saying that simplicity is relative to the third way. The third way is to develop more advanced jquery parts, the model developed by the parts with a lot of jquery
Jquery plug-in development method. For more information, see. JQuery provides two methods for development plug-ins:
JQuery. fn. extend (object );
JQuery. extend (object );
JQuery. extend (object); adds a new method to the class to
Document directory
1. simple use of jquery to Add Tag keyword prompts for the search bar
2. Use jquery In Wordpress to process sofa portraits
3. DIY WordPress contact form with jquery
4. jquery gradient drop-down menu
5. Use jquery to automatically add background Effe
Examples of on () method usage in jQuery, and jquery instances
This document analyzes the usage of the jQuery on () method. Share it with you for your reference. The specific analysis is as follows:
I. Use of the jQuery on () method:On (events, [selector], [data], fn)Events:
source code.First look at jQuery. data (element, [key], [value]) source code.Js Code:Copy codeThe Code is as follows:JQuery. extend ({Cache :{},// Please use with cautionUuid: 0,// Unique for each copy of jQuery on the page// Non-digits removed to match rinlinejQueryExpando: "jQuery" + (jQuery.
source code.First look at jQuery. data (element, [key], [value]) source code.
Js Code:
Copy codeThe Code is as follows:JQuery. extend ({Cache :{},// Please use with cautionUuid: 0,// Unique for each copy of jQuery on the page// Non-digits removed to match rinlinejQueryExpando: "jQuery" + (jQuery.
jquery plugins:
Extend jquery with $.extend ()
Add a new method to jquery through $.fn
Created using the part factory method of the jquery UI by $.widget ()
Usually we use the second method for simple plug-in development, saying that simplicity is rela
each () function, which is "jQuery. fn. each (callback, args) ", this function finally calls jQuery. each function:
Each:function(callback,args){ ReturnjQuery.each(this,callback,args);}
Let's take a look at the returned results of the jQuery. each function:
Each.function(object,callback,args){ Retumobject;}
An O
: (function (ARG) {...}) (param) This is equivalent to defining an anonymous function with a parameter of ARG, and calling this anonymous function as a parameter (function ($) {...}) param (jquery) is the same, the reason why only use $ in formal parameters is to not conflict with other libraries, so the argument is using jQuery var fn = function ($) {...};
Basic Jquery tutorial
Author: Rebecca Murphey
Original link address http://jqfundamentals.com/
With contributions by James Padolsey, Paul Irish, and others. See the GitHub repository for a complete history of contributions.
Copyright 2011
Jquery Core
$ VS $ ()
After the above preparations, we can carefully analyze the methods called by jquery objects. For exampl
"); // set the height of the element whose id is msg to 300$ ("# Msg"). width (); // return the width of the element whose id is msg$ ("# Msg"). width ("300"); // set the width of the element whose id is msg to 300$ ("Input"). val ("); // return the value of the input box of the form.$ ("Input"). val ("test"); // set the value of the form input box to test$ ("# Msg"). click (); // trigger the click event of an element whose id is msg$ ("# Msg"). click (fn
I admit that the Ajax part in the previous chapter is not well written. Don't blame me, its AjaxCodeThere are too many, and there are too many ways to jump. It is really difficult to layout and explain, but if you really want to study the source code and read it carefully, your
The gains should be huge. At least you understand how JavaScript Ajax is going. You don't know how to continue to refer to Ajax and deferred. In fact, I want you to understand deferred.
Okay, let's get down to the poi
for calling is as follows:
$.myPlugin.foo();$.myPlugin.bar('baz');
With this technique (using an independent plug-in name), we can avoid conflicts between functions in the namespace.
2. Object-level plug-in developmentObject-level plug-in development requires the following two forms :,Form 1:
(function($) {$.fn.extend({pluginName: function(opt, callback) {// Our plugin implementation code goes here.}})})(jQuery);
Form 2:
(function($) {$.fn.p
not represent all changes in jQuery 1.9, but is what we expect. For a complete and detailed list of changes, see the announcements published in The jQuery blog or visit bugs.jquery.com.
. Toggle (function, function ,... ) Method Deletion
This method binds two or more handlers to matched elements to execute alternate click events. Because it is not outdated. The former is deleted to reduce confusion and imp
Hover (Function, Function)The first function is triggered when the mouse moves over, and the second function is triggered when the mouse moves out.Style: Html code: JQuery code and Effects$ (Function(){$ ("#"). Hover (Function() {$ (This). AddClass ("Red");},Function() {$ (This). RemoveClass ("Red");});})The final result is that when you move the mouse over the layer with id a, a red style is added to the layer and the red style is removed when the la
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.