jQuery.fn.extend and jQuery.extend usage

sponsored links
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));
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of jQuery.fn.extend and jQuery.extend usage

  • Ten most widely Javascript framework

    Reprint: CSDN Recently, the well-known technology development SYS-CON Media website lists the ten most widely Javascript framework, the article said, Javascript library has become a basic site design excellence, today almost all sites with Javascript or A

  • When jQuery and Prototype conflict happened at the same time!

    <script src = " http://img.yimei.com/www/js/jquery-1.2.6.min.js "Type =" text / javascript "> </ script> <script> var jQuery = $; </ script> JQuery and everybody knows are the same method name: $ (). So the ...

  • Ajax does not refresh the page in case of implementation of the user name to determine

    Today, under the ajax implementation saw the sign box, javaeye before the implementation of a log in box is also estimated using ajax implementation. It can not refresh the page to verify the user name or verification code is correct applications. First o

  • js bind some of the ways in case notes

    Read some information online and found that some have compared several of the cow: the john resig Flexible Javascript Events (The code, itself, is very short and simple - only 15 lines long: ) dean.edwards expressed their views: My solution is very d ...

  • jQuery / Ajax / PHP / Json example of an integrated collection

    jQuery excellent Javascript is a framework for a good js packaging, provides a lot of convenient features. jQuery for ajax packaging can be called outstanding. jQuery can json file transfer protocol to transmit data (similar to xml, but also significant t

  • yiwei project management and maintenance of Javascript

    Namespace (namespace): A headache for the developers is the question how to prevent function name / class name and other people's conflicts, in an internal project team can be named among the scheduled (such as additional prefix, etc.) to solve t ...

  • ror development environment to build

    Ror about the development environment set up, records are as follows. 1. Netbeans6.5 installation download netbeans6.5 address http://zh-cn.netbeans.org/download/6.5/ml/ Ruby can download a separate version that only around 50M. II. Ruby set up the e ...

  • Rails2.0.2 change the default DB adpter

    In Rails2.0.2 rails demo ... ... MissingSourceFile in SayController # hello no such file to load - sqlite3 RAILS_ROOT: / home / kenb / rails-projects / demo ... ... Checked config / database.yml, adpter default is set become the sqlite3. Check the ra ...

  • js events dynamically add and write-off

    IE's JScript existence of memory leak bug must we all know or have heard of. This is because of IE's memory recovery manager of a design error. When we create a prepared script when a cross-reference, for example, the following code: window.o ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries