You must add a jquery file before debugging.
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "jquery. js"> </script>
<Script type = "text/javascript">
$ (Function (){
// Alert ($ ('# findclose'). closest ('div '). attr ('id '));
Var pic_length = $ ('# gd li'). length;
Var n = 0;
$ ('# Toleft'). click (function (){
If (! $ ('# Gd'). is (': animated') & n)
{
$ ('# Gd'). animate ({left: '+ = 120px'}, 500 );
N --;
}
});
$ ('# Toright'). click (function (){
If (! $ ('# Gd'). is (': animated') & pic_length> n + 5)
{
$ ('# Gd'). animate ({left: '-= 120px'}, 500 );
N ++;
}
});
})
</Script>
<Style type = "text/css">
Ul {
List-style: none;
Margin: 0px;
Padding: 0px;
Text-align: center;
}
# Gd li {
Width: 90px;
Height: 80px;
Display: block;
Float: left;
Margin: 9px 15px;
}
</Style>
<Div style = "width: 702px; height: 100px; background: # ccc; margin: 0 auto">
<Div style = "width: 30px; height: 30px; background: red; margin: 35px 10px; float: left; cursor: pointer; "id =" toleft "> </div>
<Div style = "width: 600px; height: 98px; float: left; border: 1px solid #777; overflow: hidden;">
<Ul style = "list-style: none outside none; height: 98px; display: block; background: yellow; position: relative; width: 9999em;" id = "gd">
<Li style = "background: red"> </li>
<Li style = "background: orange"> </li>
<Li style = "background: green"> </li>
<Li style = "background: navy"> </li>
<Li style = "background: blue"> </li>
<Li style = "background: purple"> </li>
<Li style = "background: pink"> </li>
<Li style = "background: gray"> </li>
</Ul>
</Div>
<Div style = "width: 30px; height: 30px; background: red; margin: 35px 10px; float: left; cursor: pointer; "id =" toright "> </div>
</Div>