jquery设置改变div背景

View Code
 1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 2 
 3     <head>
 4 
 5         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 6 
 7         <title>jQueryPad Preview</title>
 8 
 9         <script type="text/javascript" src="file:///C:/Users/yp/AppData/Local/jQueryPad/13346bf3-ccc3-4a08-a30b-cfe9f038100b/Jquery.js"></script>
10 
11         
12 
13         <style type="text/css">
14 
15         
16 
17         body
18 
19         {
20 
21             font-family: Segoe UI;
22 
23             font-size: 10pt;
24 
25             background: white;
26 
27         }
28 
29         
30 
31         </style>
32 
33         
34 
35         <script type="text/javascript">
36 
37 
38 
39 $(document).ready(
40 
41     function() {
42 
43       var e=jQuery("#hello");
44 
45        var colors=["white","yellow","orange"];
46 
47         var nextColor=0;
48 
49           $.extend({  
50 
51    chage:function(){  
52 
53       e.css("background",colors[nextColor++%colors.length]) 
54 
55    }  
56 
57 });
58 
59     setInterval("$.chage()",3000);
60 
61     });
62 
63 
64 
65         </script>
66 
67         
68 
69     </head>
70 
71     <body>
72 
73 
74 
75 <div id="hello" style="400px;height:320px;background:red;">
76 
77     
78 
79 </div>
80 
81 
82 
83 
84 
85     </body>
86 
87 </html>
原文地址:https://www.cnblogs.com/yanypan/p/2521254.html