今天小編給大家分享一下怎么用jQuery代碼實(shí)現(xiàn)選項(xiàng)聯(lián)動(dòng)輪播效果的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

專注于為中小企業(yè)提供成都做網(wǎng)站、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)掇刀免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了成百上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
代碼如下:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <link rel="stylesheet" href="css/baner.css"> <script src="js/jquery-1.11.3.js"></script> <script src="js/index.js"></script> <title>JQ輪播三級(jí)連鎖</title> </head> <body> <div class="parent"> <div class="top"> <p> <a href="">創(chuàng)意空間</a> <a href="">永恒的愛</a> <a href="">浪漫真情</a> <a href="">珍貴獨(dú)特</a> </p> </div> <div class="fours"> <a href=""><img src="img/1.jpg" alt=""></a> <a href=""><img src="img/2.jpg" alt=""></a> <a href=""><img src="img/3.jpg" alt=""></a> <a href=""><img src="img/4.jpg" alt=""></a> </div> </div> </body> </html>
CSS
*{
border:none;
margin: 0;
padding: 0;
list-style: none;
outline: none;
}
html,body{
width: 100%;
height: 100%;
}
/*方法二*/
body{
display: flex;
align-items: center;/****水平居中****/
justify-content: center;/*垂直居中*/
}
.parent{
width: 750px;
height: 400px;
/*方法一*/
/*margin: 0 auto;*/
/*position: relative;*/
/*top: 50%;*/
/*margin-top: -200px;*/
}
/*輪播*/
.top p{
width: 90%;
margin: 0 auto;
}
.top p a{
display: inline-block;
line-height: 30px;
width: 23%;
padding: 10px 0;
text-align: center;
text-decoration: none;
border: 2px solid transparent;
color: slategray;
}
.top p a.selected{
border: 2px solid #e4393c;
color: #e4393c;
}
/*圖片*/
.fours{
width: 650px;
margin: 0 auto;
height: 300px;
position: relative;
margin-top: 30px;
}
.fours a{
position: absolute;
}JS
定義變量和定時(shí)器,變量等價(jià)于eq(index)中index,自動(dòng)輪播是可以的,關(guān)鍵在于,鼠標(biāo)進(jìn)入選項(xiàng)卡區(qū)域時(shí)候,怎么對(duì)應(yīng)想要的輪播畫面,
方法:停止定時(shí)器,獲取當(dāng)前選項(xiàng)卡下標(biāo),匹配對(duì)應(yīng)的輪播畫面顯示出來。
var a=0;
var t=null;
$(function(){
$('.fours>a:not(:first-child)').hide();
t=setInterval("autoMove()",2000);
//鼠標(biāo)進(jìn)入輪播停止
$('.parent').hover(function(){clearInterval(t)},function(){t=setInterval("autoMove()",2000);});
// 當(dāng)鼠標(biāo)進(jìn)去對(duì)應(yīng)選項(xiàng)時(shí)候圖片對(duì)應(yīng)變化
$(".top p>a").hover(function(){
clearInterval(t);
var num=$(this).index();
showThis(num);
//console.log(num);
})
});
function autoMove(){
a++;
if(a>=4){
a=0;
}
play(a);
}
function play(a){
$('.fours>a').filter(":visible").fadeOut(500).parent().children().eq(a).fadeIn(1000);
$('.top p a').eq(a).addClass("selected").siblings().removeClass("selected");
}
//鼠標(biāo)進(jìn)入的情況
function showThis(sum){
$(".fours>a").eq(sum).fadeIn(1000).siblings().fadeOut(500);
$(".top p a").eq(sum).addClass("selected").siblings().removeClass("selected");
}以上就是“怎么用jQuery代碼實(shí)現(xiàn)選項(xiàng)聯(lián)動(dòng)輪播效果”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)站題目:怎么用jQuery代碼實(shí)現(xiàn)選項(xiàng)聯(lián)動(dòng)輪播效果
網(wǎng)頁路徑:http://chinadenli.net/article34/gghjpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、網(wǎng)站導(dǎo)航、靜態(tài)網(wǎng)站、全網(wǎng)營銷推廣、、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)