标签:ctrl ott function UNC htm ext text http fir
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>lbt</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#main_wnd #ctrl #nav{
list-style-type: none;
}
#main_wnd{
width: 506px;
height: 500px;
border: solid 1px red;
position: absolute;
}
#main_wnd #content div{
width: 500px;
height: 500px;
position: absolute;
}
#main_wnd #ctrl{
margin-top: 500px;
}
#main_wnd #ctrl li{
float: left;
width: 100px;
height: 30px;
text-align: center;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
</style>
</head>
<body>
<div id="main_wnd">
<div id="content">
<div>第一个</div>
<div>第二个</div>
<div>第三个</div>
<div>第四个</div>
<div>第五个</div>
</div>
<div id="ctrl">
<ul id="nav">
<li>一</li>
<li>二</li>
<li>三</li>
<li>四</li>
<li>五</li>
</ul>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
//将第一个li左边的border加上
$(‘#main_wnd #ctrl #nav li:first‘).css(‘border-left‘,‘1px solid #ccc‘);
//隐藏除了第一个的照片
$(‘#main_wnd #content div:not(:first)‘).css(‘display‘,‘none‘);
var bq = $(‘#main_wnd #ctrl #nav li‘);
var content = $(‘#main_wnd #content div‘);
//模仿鼠标悬浮在第一个li的情景
bq[0].style.borderTop = ‘1px solid #fff‘;
var i = 0;
//计时轮播
setInterval(function(){
$(‘#main_wnd #ctrl #nav li‘).css(‘border-top‘,‘1px solid #ccc‘);
bq[i].style.borderTop = ‘1px solid #fff‘;
content.css(‘display‘,‘none‘);
content[i].style.display = ‘block‘;
i++;
if (i==5) {i=0;}
},2000)
//鼠标悬浮轮播
$(‘#main_wnd #ctrl #nav‘).mouseover(function(){
clearInterval();
var tg = event.target;
var idx = $(tg).index();
$(‘#main_wnd #ctrl #nav li‘).css(‘border-top‘,‘1px solid #ccc‘);
tg.style.borderTop = ‘1px solid #fff‘;
content.css(‘display‘,‘none‘);
content[idx].style.display = ‘block‘;
});
</script>
</body>
</html>
标签:ctrl ott function UNC htm ext text http fir
原文地址:https://www.cnblogs.com/tell-me-why-not/p/9564667.html