Jquery plug in writing concise tutorial

  • 2020-03-30 02:27:32
  • OfStack


 //; For better compatibility, start with a semicolon
 ;(function($){//Use $as a parameter for the anonymous function
  //$.fn.extend extension
      "color":function(value){//Color writes its own plug-in method name
       //JQuery provides CSS methods that can be directly written as this.css (" properties ", "values");
       return this.css("color",value);

 })(jQuery);//Jquery is passed here as an argument to an anonymous function

 function red(){
  alert($("#div").color()+" Proof that plug-ins are available ");
  alert($("#div").color("red")+" Verify that the plug-in returns one Jquery object ");

Examples of using plug-ins in HTML:

      <div id="div" onclick="red()">dddddddddddddddd</div>

Related articles: