廢話不多說,直接上圖看效果:
需求: 點(diǎn)擊左右按鈕實(shí)現(xiàn)切換用戶圖片與信息;
原理: 點(diǎn)擊右側(cè)左側(cè)按鈕,把3號(hào)的樣式給2號(hào),2號(hào)的給1號(hào),1號(hào)的給5號(hào),5號(hào)的給4號(hào),4號(hào)的樣式給3號(hào),然后根據(jù)現(xiàn)在是第幾張圖片切換成對(duì)應(yīng)的文字;
步驟:
1.讓頁面加載出所有盒子的樣式;
2.把兩側(cè)按鈕綁定事件(調(diào)用同一個(gè)方法,只有一個(gè)參數(shù),true為正向旋轉(zhuǎn),false為反向旋轉(zhuǎn));
3.書寫函數(shù): 操作函數(shù):左按鈕:刪除第一個(gè),添加到最后一個(gè); 右按鈕:刪除最后一個(gè),添加到第一個(gè);
4.定義變量,根據(jù)對(duì)應(yīng)變量切換對(duì)應(yīng)的文字內(nèi)容;
代碼事例如下:
HTML代碼:
寫法思路:
1.定義好5張圖片,進(jìn)行圖片信息切換;
2.書寫好你需要切換的文字內(nèi)容,定義一個(gè)ID;
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>學(xué)員信息輪播圖</title> <link rel="stylesheet" href="css/css.css" rel="external nofollow" /> <script src="js/jquery1.0.0.1.js"></script> <script src="js/js.js"></script> </head> <body> <div class="feedbackwrap" id="feedbackwrap"> <div class="feedbackslide" id="feedbackslide"> <ul> <!--五張圖片--> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img src="images/1.png" alt=""/></a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img src="images/2.png" alt=""/></a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img src="images/3.png" alt=""/></a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img src="images/4.png" alt=""/></a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img src="images/5.png" alt=""/></a></li> </ul> <!--左右切換按鈕--> <div class="feedbackarrow" id="feedbackarrow"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="feedbackprev"></a> <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="feedbacknext"></a> </div> </div> <div class="feedbackname"> <p class="p1">學(xué)員</p> <p class="p2" id="feedstudent">歐陽常斌3</p> </div> </div> </body> </html>
網(wǎng)頁名稱:原生JS實(shí)現(xiàn)旋轉(zhuǎn)輪播圖+文字內(nèi)容切換效果【附源碼】-創(chuàng)新互聯(lián)
網(wǎng)站路徑:http://chinadenli.net/article40/dgpseo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、面包屑導(dǎo)航、定制網(wǎng)站、電子商務(wù)、網(wǎng)站建設(shè)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容