This article mainly introduces the multi-screen image layer switching effect of jquery, can realize the click Switch effect of multiple layers, design the operation skill of jquery mouse event and style, need friend can refer to
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5, 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11 9 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148-149 150 151 152 153 154 155 156 157 158 159 160 161-162 |
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Untitled document </title> <script type=" Text/javascript "src=" Jquery-1.6.2.min.js " ></script> <style type= "Text/css" > ul{list-style:none;margin:0;padding:0;} li{float:left. xing_focus{width:875px; height:800px; overflow:hidden;border:1px solid red; Xing_focus ul{width:3500px}. bnt {float:left;width:300px;height:20px; border:1px solid red; BNT li{Width:18px;heig ht:18px; background:red; Cursor:pointer; Margin-right:10px;float:left; BNT. sli{background:blue; next{width:100px;height:100px; background: #990000; float:left; cursor:pointer; pre{ idth:100px;height:100px; Background: #009; float:left; cursor:pointer;margin-right:30px; }. list1{width:875px;height:500px;background:red;} . list2{width:875px;height:500px;background:black; list3{Width:875px;height:500px;background:pink; list4{ Width:875px;height:500px;background:blue; } </style> </head> <body> <div class= "Xing_focus" id= "box" > <ul class= "IMGs" id= "actor" > & Lt;li class= "List1" > <img src= "baidu_sylogo1.gif"/> </li> <li class= "List2" > <img src= "baidu_ Sylogo1.gif "/> </li> <li class=" List3 "> <img src=" baidu_sylogo1.gif "/> </li> <li class=" List4 "> <img src=" baidu_sylogo1.gif "/> </li> </ul> <ul class=" BNT "id=" BNT "> </ul> <div class= "Pre" id= "pre" > previous </div> <div class= "Next" id= "Next" > Next </div> </div> < Script type= "Text/javascript" > $ (Window). Load (function () {var Liw = $ ("#actor Li:first"). width (); var LiL = $ ("#actor Li "). length; Alert (LIW) var lis = $ ("#actor li"). length; for (i=0;i<lis;i++) {$ ("#bnt"). Append ("<li></li>") $ ("#bntLi:first "). AddClass (" SLI "); }; $ ("#bnt Li"). each (the function (index) {$ (this). Click (function () {if ($ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Animate ({"MarginLeft":-index*liw},500,function () {$ ("#bnt li"). Removeclass ("SLI"); $ ("#bnt li"). EQ (index). addclass ("SLI"); }); }; }); }); Settime=window.setinterval (atuoscroll,2000); $ ("#box"). Hover (function () {window.clearinterval (settime);},function () {Settime=window.setinterval (Atuoscroll, 2000); }); $ ("#next"). Click (function () {var UlM =parseint ($ ("#actor"). CSS (" Margin-left ")); if (ulm==-(liL-1) *liw) &&$ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Animate ({"MarginLeft": 0+ "px"}, 500,function () {$ ("#bnt li"). Removeclass ("SLI"); $ ("#bnt Li:first"). AddClass ("SLI");}); else if ($ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Animate ({"MarginLeft": ulm-liw+ "px"},500,function () {var UlM =parseint ($ ("#actor"). CSS ("Margin-left"); var num =-ulm/liw $ ("#bnt li"). Removeclass ("SLI"); $ ("#bnt Li").EQ (num). addclass ("SLI"); }); }; }); $ ("#pre"). Click (function () {var UlM =parseint ($ ("#actor"). CSS (" Margin-left ")); if (ulm==0&&$ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Animate ({"MarginLeft": -2625+ "px"},500, Function () {$ ("#bnt li"). Removeclass ("SLI"); $ ("#bnt li:last"). AddClass ("SLI");}); else if ($ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Animate ({"MarginLeft": ulm+liw+ "px"},500,function () {var UlM =parseint ($ ("#actor"). CSS ("Margin-left"); var num =-ulm/liw $ ("#bnt li"). Removeclass ("SLI"); $ ("#bnt li"). EQ (num). addclass ("SLI"); }); }; }); //end function Atuoscroll () {var Liw = $ ("#actor Li:first"). width (); var LiL = $ ("#actor li"). length; var UlM =parseint ($ ("#actor"). CSS ("Margin-left"); if (ulm==-(liL-1) *liw) &&$ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Stop (); $ (#actor). Animate ({" MarginLeft ": 0},500,function () {$ (" #bnt li "). Removeclass (" SLI "); $ (" #bnt Li:first "). addclass ("SLI"); }); else if ($ ("#actor"). Is (": animated") ==false) {$ ("#actor"). Stop (); $ ("#actor"). Animate ({"MarginLeft": ulm-liw},500, function () {var UlM =parseint ($ ("#actor"). CSS ("Margin-left"): var num =-ulm/liw $ ("#bnt li"). Removeclass ("SLI"); $ ("#b NT Li "). EQ (num). addclass (" SLI "); }); }; }; </script> </body> </html> |
I hope this article will help you with your jquery programming.