jQuery.fn.extend and jQuery.extend usage

demo: jquery itself does not provide jQuery.color () This method, if we need the methods of the jQuery itself be extended, then we need is jQuery.fn.extend.

jQuery.fn.extend({
    color:function(val)
    {
          if(val==undefined){

               return $(this).css("color");
            }else{

              return $(this).css("color",val);
            }
    }
})

$(this).color("red");// On the jquery object color settings
alert($(this).color());// Gets the color of the jquery object  , With a pop-up dialog box

2.jQuery.extend expansion of the jQuery object, can be understood as a static method, no instance of jQuery, you can use

jQuery.extend( {

    myshow:function(a,b)
    {
     return a+b;
    }
})

Call: alert ($. Add (3, 4));

分类:Web 时间:2010-06-23 人气:171
本文关键词: demo fn jquery static method
分享到:
blog comments powered by Disqus

相关文章

  • Instance constructor is not a static method? 2010-04-25

    As title. The answer depends on your heart "static" to refer to something. See a recent forum posts: renpeng301 writes If you are not familiar with the JVM instructions, see the things that really difficult to understand a very intuitive default

  • JQuery common method Essentials 2010-04-28

    Attribute: $ ("P"). AddClass (css style defined type); to add an element of style $ ("Img"). Attr ((src: "test.jpg", alt: "test Image")); to add an element, attribute / value, the parameter is the map $ ("Img&q

  • JQuery common method of collection 2010-07-02

    Attribute: $ ("P"). AddClass (css style defined type); to add an element of style $ ("Img"). Attr ((src: "test.jpg", alt: "test Image")); to add an element, attribute / value, the parameter is the map $ ("Img&q

  • Struts2 page called class static method 2010-03-23

    java struts ognl static method Using struts2, in the jsp page, you can access through the ognl class static methods. The format of the expression @ [type the full name (including the package path)] @ [method name | value name], for example: @ java.la

  • From the project on JAVA in the static method in the use of multi-threaded environment 2010-03-30

    Recently to be a relatively high real-time systems, database access is very frequent. Database access in this project were I made most of the static method. (This should not be very good, can not play dao mode of advantage, but to make do with it) be

  • java static method call 2010-04-17

    public class TestMethod{ public static void main(String args[]){ printInfo() ; // Call printInfo() Method printInfo() ; // Call printInfo() Method printInfo() ; // Call printInfo() Method System.out.println("Hello World!!!") ; int one = addOne(1

  • Python use the static method 2010-04-19

    1, the Python method in a class set to static (ie can be called by class name), just before the method name with "@ staticmethod" class PersonManager(object): @staticmethod def saveOrUpdatePerson(person): ''' Update a contact is saved. ''' name

  • JQuery startup method 2010-05-04

    Reference version: 1.2.6 Start from the following categories, you can clearly see several events ready written: $ ('Document'). Ready (function (){}); $ (). Ready (function (){}); $ (Function (){}); jQuery.fn = jQuery.prototype = { init: function( se

  • Use the cache to prevent jQuery Load method [reproduced] 2010-07-29

    Use the cache to prevent jQuery Load method [reproduced] Cache this stuff, to a certain extent, to speed up the page load, but often give us trouble. In my last article in a brief introduction to use jQuery in the Load method. In practice, we may run

  • Instance method. Class methods. Static method 2010-08-09

    python different with Java. In Java, only instance methods and static methods of the points. The python has had an instance method, class methods, static methods of the points. There are two major differences between the three: 1, call. Instance meth

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.109 (s). 12 q(s)