jquery left and right scrolling focus graph banner picture mouse over Display page Up button _jquery

Source: Internet
Author: User
jquery left and right scrolling focus map banner picture, mouse over show page down
For pages with wide and high widths

Demonstrate
Copy Code code as follows:

<div class= "Bannerbox" >
<div id= "Focus" >
<ul>
<li><a href= "http://www.freejs.net/" target= "_blank" >
</a></li>
<li><a href= "http://www.freejs.net/" target= "_blank" >
</a></li>
<li><a href= "http://www.freejs.net/" target= "_blank" >
</a></li>
<li><a href= "http://www.freejs.net/" target= "_blank" >
</a></li>
</ul>
</div>
</div>

Copy Code code as follows:

@charset "Utf-8";
img {border:0px;}
. bannerbox {width:320px; height:150px; overflow:hidden; margin:0px Auto;}
#focus {width:320px; height:150px; clear:both; overflow:hidden; position:relative; float:left;}
#focus ul {width:320px; height:150px; float:left; position:absolute; clear:both; padding:0px; margin:0px;}
#focus ul li {float:left; width:320px; height:150px; overflow:hidden; position:relative; padding:0px; margin:0px; }
#focus. prenext {width:250px; height:150px; position:absolute; top:0px; cursor:pointer;}
#focus. Pre {left:0 background:url (.) /images/sprite.png) No-repeat left center; }
#focus. Next {rightright:0; Background:url (.. /images/sprite1.png) no-repeat Rightright Center; }

JS file
Copy Code code as follows:

$ (function () {
var swidth = $ ("#focus"). width ();
var len = $ ("#focus ul li"). length;
var index = 0;
var Pictimer;
var btn = "<div class= ' btnbg ' ></div><div class= ' btn ' >";
for (var i = 0; i < len; i++) {
BTN = "<span></span>";
}
BTN + + </div><div class= ' prenext pre ' ></div><div class= ' prenext Next ' ></div> ';
$ ("#focus"). Append (BTN);
$ ("#focus. BTNBG"). CSS ("opacity", 0);
$ ("#focus. BTN span"). CSS ("opacity", 0.4). MouseEnter (function () {
Index = $ ("#focus. BTN span"). index (this);
Showpics (index);
). EQ (0). Trigger ("MouseEnter");
$ ("#focus. Prenext"). CSS ("opacity", 0.0). Hover (function () {
$ (this). Stop (True, false). Animate ({"opacity": "0.5"}, 300);
}, function () {
$ (this). Stop (True, false). Animate ({"opacity": "0"}, 300);
});
$ ("#focus. Pre"). Click (function () {
index-= 1;
if (index = = 1) {index = len-1;}
Showpics (index);
});
$ ("#focus. Next"). Click (function () {
Index + 1;
if (index = = len) {index = 0;}
Showpics (index);
});
$ ("#focus ul"). CSS ("width", swidth * (len));
$ ("#focus"). Hover (function () {
Clearinterval (Pictimer);
}, function () {
Pictimer = setinterval (function () {
Showpics (index);
index++;
if (index = = len) {index = 0;}
}, 2800);
}). Trigger ("MouseLeave");
function Showpics (index) {
var nowleft =-index * swidth;
$ ("#focus ul"). Stop (True, false). Animate ({"Left": Nowleft}, 300);
$ ("#focus. BTN span"). Stop (True, false). Animate ({"opacity": "0.4"},). EQ (index). Stop (True, false). Animate ({" Opacity ":" 1 "}, 300);
}
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.