jquery圖片切換實(shí)例分析
本文實(shí)例講述了jquery圖片切換實(shí)現(xiàn)方法。分享給大家供大家參考。具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="javascript" src="inc/jquery-1.4.2.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標(biāo)題文檔</title> </head> <style type="text/css"> #butt div{ width:122px; height:32px; float:left; text-align:center; } </style> <script language="javascript"> function tab_q(now_id) { if(now_id == null) { //alert($("#butt").find("div:visible").attr("id")) c_show_id = $("#cont").find("div:visible").attr("id"); //此時(shí)顯示按鈕的ID名稱 nums_id = c_show_id.substring(1,3); //截取B1后面的1,作為字符串放到C后面 b_show_id = "b"+ nums_id; //此時(shí)顯示內(nèi)容的ID名稱 nums_next = parseInt(nums_id)+1 //alert(nums_next) if(nums_next<=8) //如果到最后一個(gè)的話,那么就要跳回第一個(gè) { } else { nums_next = 1 } }else { nums_next = now_id.substring(1,3); } $("#cont div").hide(); //讓所有的上面的div中的圖片消失。 //是為了羅出地方讓下一張圖片出現(xiàn)的。 $("#butt div").css({border:'#FF0000 0px solid'}); //讓所有按鈕的邊框消失。是為了讓下一個(gè)按鈕有邊框, //alert("#"+"c"+nums_next) $("#c"+nums_next).fadeIn() //讓上面的圖片淡出來 $("#b"+nums_next).css({border:'#FF0000 1px solid'}); //給下面對(duì)應(yīng)的按鈕加上邊框,當(dāng)然這里也可以做其他的效果 //加邊框只是為了測(cè)試 } $(function(){ //當(dāng)頁面加載完成 auto = setInterval("tab_q()",2000); //這里修改切換的時(shí)間的 $("#cont div").each(function(i,n){ $(n).hover( function(){ clearInterval(auto) }, function(){auto=setInterval("tab_q()",2000); } ) }) $("#butt div").each(function(i,n){ $(n).hover( function(){ clearInterval(auto); tab_q($(this).attr("id")) },function(){auto=setInterval("tab_q()",2000); } ) }) }) </script> <body> <div style="width:980px; height:275px;"> <div style="width:980px; height:241px; overflow:hidden; text-align:center" id="cont"> <div style="width:980px; height:241px; text-align:center" id="c1"><img src="images/xmjz.jpg" width="980"/> </div> <div style="width:980px; height:241px; display:none; text-align:center" id="c2"> <img src="images/4037.jpg" width="980" height="241"/> </div> <div style="width:980px; height:241px; display:none; text-align:center" id="c3"><img src="images/4041.jpg" width="980" height="241"/></div> <div style="width:980px; height:241px; display:none; text-align:center" id="c4"> <img src="images/xmjz.jpg" width="980"/> </div> <div style="width:980px; height:241px; display:none;text-align:center" id="c5"> <img src="images/xmjz.jpg" width="980"/> </div> <div style="width:980px; height:241px; display:none;text-align:center" id="c6"> <img src="images/xmjz.jpg" width="980"/> </div> <div style="width:980px; height:241px; display:none;text-align:center" id="c7"> <img src="images/xmjz.jpg" width="980"/> </div> <div style="width:980px; height:241px; display:none;text-align:center" id="c8"> <img src="images/xmjz.jpg" width="980"/> </div> </div> <div style="width:980px; height:31px; border:#FF0000 0px solid" id="butt"> <div style="background-image:url(images/xmbtn_1.png)" id="b1"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b2"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b3"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b4"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b5"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b6"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b7"> </div> <div style="background-image:url(images/xmbtn_2.png)" id="b8"> </div> </div> </div> </body> </html>
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
- jquery實(shí)現(xiàn)圖片切換代碼
- 完美JQuery圖片切換效果的簡(jiǎn)單實(shí)現(xiàn)
- 基于jquery實(shí)現(xiàn)左右按鈕點(diǎn)擊的圖片切換效果
- 基于jquery實(shí)現(xiàn)鼠標(biāo)滾輪驅(qū)動(dòng)的圖片切換效果
- jQuery實(shí)現(xiàn)的Tab滑動(dòng)選項(xiàng)卡及圖片切換(多種效果)小結(jié)
- jQuery插件Slider Revolution實(shí)現(xiàn)響應(yīng)動(dòng)畫滑動(dòng)圖片切換效果
- jquery簡(jiǎn)單實(shí)現(xiàn)圖片切換效果的方法
- jQuery插件slick實(shí)現(xiàn)響應(yīng)式移動(dòng)端幻燈片圖片切換特效
- jquery簡(jiǎn)單圖片切換顯示效果實(shí)現(xiàn)方法
- 完美兼容各大瀏覽器的jQuery插件實(shí)現(xiàn)圖片切換特效
- 基于jQuery實(shí)現(xiàn)的幻燈圖片切換
相關(guān)文章
jquery動(dòng)態(tài)增加text元素以及刪除文本內(nèi)容實(shí)例代碼
這段代碼是通過jquery動(dòng)態(tài)增加限定數(shù)額的text,以及清除文本內(nèi)容,用到了after()方法追加元素,具體實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助2013-07-07jQuery簡(jiǎn)單實(shí)現(xiàn)遍歷數(shù)組的方法
這篇文章主要介紹了jQuery簡(jiǎn)單實(shí)現(xiàn)遍歷數(shù)組的方法,涉及jQuery遍歷數(shù)組的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04JQuery中使用ajax傳輸超大數(shù)據(jù)的解決方法
這篇文章主要介紹了JQuery中使用ajax傳輸超大數(shù)據(jù)的解決方法,也就是比較多的數(shù)據(jù),超過max_upload_size等設(shè)置,本文方法在chrome瀏覽器下測(cè)試通過,需要的朋友可以參考下2014-07-07jQuery 浮動(dòng)廣告實(shí)現(xiàn)代碼
用jquery實(shí)現(xiàn)的浮動(dòng)廣告代碼,需要的朋友可以參考下。2008-12-12基于jquery實(shí)現(xiàn)的服務(wù)器驗(yàn)證控件的啟用和禁用代碼
用戶點(diǎn)擊下一步時(shí),不對(duì)Display=none的新增區(qū)域表單進(jìn)行驗(yàn)證,需要在用戶點(diǎn)擊“取消增加時(shí)”,禁用服務(wù)器驗(yàn)證控件。反之,啟用服務(wù)器驗(yàn)證控件。2010-04-04讀jQuery之七 判斷點(diǎn)擊了鼠標(biāo)哪個(gè)鍵的代碼
jQuery中的which即可以是鍵盤的鍵值,也可以是鼠標(biāo)的鍵值。2011-06-06