jQuery簡單實現(xiàn)仿京東分類導航層效果
本文實例講述了jQuery簡單實現(xiàn)仿京東分類導航層效果。分享給大家供大家參考,具體如下:
<script src="jquery-1.11.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var alink01 = $(".item > ul"); alink01.hover(function () { //alert div var divId = $(this).find("div").attr("id"); var div = $("#" + divId); //要浮動在這個元素旁邊的層 div.css("position", "absolute"); //讓這個層可以絕對定位 var self = $(this); //當前對象 div.css("display", "block"); var p = self.position(); //獲取這個元素的left和top var x = p.left + self.width(); //獲取這個浮動層的left div.css("left", x + 45); //20140916修改 div.css("top", p.top); div.show(); //mouseenter $(this).removeClass("unfocus").addClass("focus"); }, function () { var divId = $(this).find("div").attr("id"); var div = $("#" + divId); //要浮動在這個元素旁邊的層 div.css("display", "none"); //mouseleave $(this).removeClass("focus").addClass("unfocus"); }); }); </script>
<div class="leftbody"> <div class="item"> <span>全部分類</span> <ul class="focus"> <li ><strong>php</strong> <br /> php基本語法 php實例 </li> </ul> <ul class="unfocus"> <li ><strong>java</strong> <br /> java語法 java面向對象 </li> </ul> <ul class="unfocus"> <li ><strong>Python</strong> <br /> Python語法 Python圖形處理 </li> </ul> <ul class="unfocus"> <li ><strong>javascript</strong> <br /> javascript幻燈片 javascript網(wǎng)頁特效 </li> </ul> <ul class="unfocus"> <li ><strong>C#</strong> <br /> C#桌面應用程序 C#網(wǎng)絡程序 </li> </ul> <ul class="unfocus"> <li ><strong>VC++</strong> <br /> VC++系統(tǒng)程序開發(fā) VC++網(wǎng)絡程序 </li> </ul> <ul class="unfocus"> <li ><strong>Delphi</strong> <br /> Delphi桌面程序 Delphi游戲開發(fā) </li> </ul> </div> </div>
更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jquery中Ajax用法總結》、《jQuery表格(table)操作技巧匯總》、《jQuery拖拽特效與技巧總結》、《jQuery擴展技巧總結》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結》、《jquery選擇器用法總結》及《jQuery常用插件及用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
相關文章
jQuery實現(xiàn)的購物車物品數(shù)量加減功能代碼
這篇文章主要介紹了jQuery實現(xiàn)的購物車物品數(shù)量加減功能,涉及jQuery針對鼠標事件的響應及頁面元素動態(tài)操作相關技巧,需要的朋友可以參考下2016-11-11jQuery中bind(),live(),delegate(),on()綁定事件方法實例詳解
這篇文章主要介紹了jQuery中bind(),live(),delegate(),on()綁定事件方法,結合實例形式詳細分析了bind(),live(),delegate(),on()方法綁定事件的具體使用技巧,并對比分析了四種方式的異同點,需要的朋友可以參考下2016-01-01淺談jQuery中對象遍歷.eq().first().last().slice()方法
本文給大家分析了jQuery中的對象遍歷.eq().first().last().slice()方法的使用,以及他們之間的區(qū)別,jQuery源碼中的使用。2014-11-11jQuery簡單實現(xiàn)iframe的高度根據(jù)頁面內容自適應的方法
這篇文章主要介紹了jQuery簡單實現(xiàn)iframe的高度根據(jù)頁面內容自適應的方法,給出了2種簡單實現(xiàn)方法,涉及jQuery針對頁面高度的動態(tài)獲取與設置相關技巧,需要的朋友可以參考下2016-08-08