jQuery 插件

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4   <meta charset="utf-8">
 5   <meta name="viewport" content="width=device-width">
 6   <title>jQuery 插件</title>
 7 <script src="https://code.jquery.com/jquery-2.0.3.js"></script>
 8 </head>
 9 <body>
10 <ul class='u1'>
11   <li>1</li>
12   <li>2</li>
13   <li>3</li>
14 </ul>
15   <ul class='u2'>
16   <li>4</li>
17   <li>5</li>
18   <li>6</li>
19 </ul>
20 </body>
21 </html>
 1 $(function(){
 2   $.fn.extend({
 3     changecolor:function(){
 4       return this.each(function(){
 5         this.style.color='red';
 6       });
 7     }
 8   });
 9   
10   $('.u1 li').changecolor();
11 })

原文地址:https://www.cnblogs.com/johnhery/p/9799964.html