JQuery Picture scrolling Carousel Sample Code _jquery

Source: Internet
Author: User
The complete project is in the attachment
Copy Code code as follows:

<! DOCTYPE html>
<title> Picture Switching </title>
<script type= "Text/javascript" src= "Js/jquery-1.11.0.min.js" ></script>
<script type= "Text/javascript" >
var num = 0
$ (function () {
$ ("Div ol li"). MouseOver (function (e) {
$ (this). attr ("Class", "current");
$ (this). Siblings (). attr ("Class", ""); The sibling node's class attribute is set to null
Alert ($ (' ul '). Index ())
num = $ (' ul '). Index () + 2
var index = $ (this). index (); Record the index of the selected Li tag in ul
There are cascading phenomena in the picture to display the current picture, set the Z-index value of the current picture to be larger than the other sibling elements
$ ("Div ul li"). EQ (index). css ({"Left": "650px", "ZIndex": num})
$ ("Div ul li"). EQ (index). siblings (). CSS ("ZIndex", num-1);
Animation effect, the picture from the right fly into
$ ("Div ul li"). EQ (index). Animate ({left: "0"},500)

});

});
</script>
<style type= "Text/css" >
*{margin:0px;padding:0px;border:0px;}
Ul,ol{list-style:none;}
. all{width:650px;height:250px;margin:100px auto;position:relative;border:1px Solid Crimson;overflow:hidden;
. all ul{position:relative;z-index:1;position:relative;

* * Son never father
. all UL li{position:absolute;left:0;top:0px;

. all ol{position:absolute;z-index:2; right:10px;bottom:10px;
. All ol Li{width:20px;height:20px;background: #333; border:1px solid #509629; Font-weight:
bold;text-align:center;line-height:20px;float:left;margin-left:10px;margin-top:10px;}

. All ol. current{width:30px;height:30px;line-height:30px;border:1px solid red;margin-top:0px;
Cursor:pointer;}
</style>
<body>
<div class= "All" >
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<ol>
<li class= "Current" >1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ol>
</div>
</body>

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.