最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實現(xiàn)自定義右鍵菜單的樹狀菜單效果

 更新時間:2015年09月02日 11:21:46   作者:企鵝  
這篇文章主要介紹了jQuery實現(xiàn)自定義右鍵菜單的樹狀菜單效果,涉及jquery鼠標事件及頁面元素操作的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了jQuery實現(xiàn)自定義右鍵菜單的樹狀菜單效果。分享給大家供大家參考。具體如下:

這是一款基于jQuery的自定義右鍵菜單,在樹狀結(jié)構(gòu)的子節(jié)點(下級沒有節(jié)點)上單擊右鍵才會彈出自定義菜單,而且菜單是自動根據(jù)鼠標位置來定位的。當鼠標在菜單以外的任意空白處單擊一下后會自動消失。這里想特別說明一點所謂的“菜單以外”,可以有兩種解剖方式——1、除了鼠標在菜單區(qū)域內(nèi)的所有位置;2、如下圖所示的A、B、C、D四個區(qū)域。顯然用第一種方法來剖析會更簡單直接一點。源碼中的!IsInArea就表示此方法。

運行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/jquery-zdy-right-button-menu-style-codes/

具體代碼如下:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery自定義右鍵菜單</title>
<style type="text/css">
body {
  font-size: 12px;
  margin: 0px;
  padding: 0px;
}
form,div,ul,li {
  margin: 0px;
  padding: 0px;
  list-style-type: none;
  overflow: hidden;
}
h1,h2,h3,h4,h5 {
  font-size: 12px;
  margin: 0px;
  padding: 0px;
}
a {
  text-decoration: none;
}
.layout {
  width: 993px;
  clear: both;
  margin-right: auto;
  margin-left: auto;
  border-top-width: 0px;
  border-right-width: 4px;
  border-bottom-width: 0px;
  border-left-width: 4px;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-left-style: solid;
  border-top-color: #000000;
  border-right-color: #000000;
  border-bottom-color: #000000;
  border-left-color: #000000;
  overflow: hidden;
}
.layout2 {
  width: 942px;
  margin-right: auto;
  margin-left: auto;
}
.Content {
  background-color: #376285;
}
.contentBg {
  background-color: #173043;
}
div, ul, li {
 margin: 0px;
 padding: 0px;
 list-style-type: none;
}
body {
 background-color: #FFFFFF;
 font-size: 12px;
 margin: 0px;
 padding: 0px;
}
#TreeList {
 background-color: #FFFFFF;
 margin-top: 6px;
 margin-right: 9px;
 margin-bottom: 6px;
 margin-left: 9px;
 border: 1px solid #5d7b96;
 padding-bottom: 6px;
 padding-left: 6px;
}
#TreeList .mouseOver {
 background-color: #FAF3E2;
}
#TreeList .ParentNode {
 line-height: 21px;
 height: 21px;
 margin-top: 2px;
 clear: both;
}
#TreeList .ChildNode {
 background-image: url(images/Sys_ModuleIcos.png);
 background-position: 15px -58px;
 padding-left: 39px;
 line-height: 21px;
 background-repeat: no-repeat;
 border-top-width: 0px;
 border-right-width: 0px;
 border-bottom-width: 1px;
 border-left-width: 0px;
 border-top-style: dashed;
 border-right-style: dashed;
 border-bottom-style: dashed;
 border-left-style: dashed;
 border-top-color: #aabdce;
 border-right-color: #aabdce;
 border-bottom-color: #aabdce;
 border-left-color: #aabdce;
 cursor: default;
 clear: both;
 height: 21px;
 color: #314f6a;
}
#TreeList .title {
 float: left;
}
#TreeList .input {
 font-size: 12px;
 line-height: 18px;
 color: #FFF;
 height: 16px;
 background-color: #3F6B8F;
 width: 120px;
 text-align: center;
 margin-top: 1px;
 border-top-width: 1px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #1F3547;
 border-right-color: #FFF;
 border-bottom-color: #FFF;
 border-left-color: #1F3547;
 float: left;
}
#TreeList .editBT {
 float: left;
 overflow: visible;
}
#TreeList .editBT .ok {
 background-image: url(images/Sys_ModuleIcos.png);
 background-repeat: no-repeat;
 background-position: 0px -89px;
 height: 13px;
 width: 12px;
 float: left;
 margin-left: 3px;
 padding: 0px;
 margin-top: 3px;
 cursor: pointer;
}
#TreeList .editBT .cannel {
 background-image: url(images/Sys_ModuleIcos.png);
 background-repeat: no-repeat;
 background-position: 0px -120px;
 float: left;
 height: 13px;
 width: 12px;
 margin-left: 3px;
 padding: 0px;
 margin-top: 3px;
 cursor: pointer;
}
#TreeList .editArea {
 float: right;
 color: #C3C3C3;
 cursor: pointer;
 margin-right: 6px;
}
#TreeList .editArea span {
 margin: 2px;
}
#TreeList .editArea .mouseOver {
 color: #BD4B00;
 border-top-width: 1px;
 border-right-width: 1px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #C9925A;
 border-right-color: #E6CFBB;
 border-bottom-color: #E6CFBB;
 border-left-color: #C9925A;
 background-color: #FFFFFF;
 margin: 0px;
 padding: 1px;
}
#TreeList .ParentNode .title {
 color: #314f6a;
 cursor: pointer;
 background-image: url(images/Sys_ModuleIcos.png);
 background-repeat: no-repeat;
 padding-left: 39px;
}
#TreeList .ParentNode.show .title {
 font-weight: bold;
 background-position: 3px -27px;
}
#TreeList .ParentNode.hidden .title {
 background-position: 3px 4px;
}
#TreeList .ParentNode .editArea {
 color: #999; 
}
#TreeList .ParentNode.show {
 background-color: #d1dfeb;
 border-top-width: 0px;
 border-right-width: 0px;
 border-bottom-width: 1px;
 border-left-width: 1px;
 border-top-style: solid;
 border-right-style: solid;
 border-bottom-style: solid;
 border-left-style: solid;
 border-top-color: #5d7b96;
 border-right-color: #5d7b96;
 border-bottom-color: #5d7b96;
 border-left-color: #5d7b96;
}
#TreeList .ParentNode.hidden {
 border-top-width: 0px;
 border-right-width: 0px;
 border-bottom-width: 1px;
 border-left-width: 0px;
 border-top-style: dashed;
 border-right-style: dashed;
 border-bottom-style: dashed;
 border-left-style: dashed;
 border-top-color: #aabdce;
 border-right-color: #aabdce;
 border-bottom-color: #aabdce;
 border-left-color: #aabdce;
}
#TreeList .Row {
 clear: both;
 margin-left: 24px;
 background-image: url(images/Sys_ModuleIcos2.png);
 background-repeat: repeat-y;
 background-position: 7px 0px;
}
h1 {
 font-size: 12px;
 line-height: 24px;
 color: #FFF;
 background-color: #396384;
 text-align: center;
 margin: 0px;
 padding: 0px;
}
#OpLimits_Menu {
 position: absolute;
 width: 70px;
 cursor: default;
 filter: Alpha(Opacity=90);
}
#OpLimits_Menu ul {
 background-color: #d5effc;
 border: 1px solid #3e8dad;
}
#OpLimits_Menu ul li {
 line-height: 18px;
 color: #496D81;
 text-align: center;
 letter-spacing: 0.3em;
 height: 18px;
 cursor: pointer;
}
#OpLimits_Menu ul .onmouse {
 background-image: url(images/bt1.gif);
 background-repeat: repeat-x;
 color: #324A58;
}
</style>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script type="text/javascript">
var Mouse_X,Mouse_Y;
var TMenu_X0,TMenu_Y0;
var MousePostion;
$(document).ready(function(e) {
 var PrentNodeClass = 'ParentNode';//父節(jié)點的標識
 var ChildNodeClass = 'ChildNode';//沒有下級子節(jié)點的標識
 var ChildrenListClass = 'Row';//子節(jié)點被包著的外層樣式
 var TModuleNode,TChildNode,TModuleNodeName;
 TModuleNode = $('#TreeList .'+PrentNodeClass);//頂層節(jié)點
 TChildNode = $('.'+ChildNodeClass);
 TModuleNodeName = $('#TreeList .' + PrentNodeClass + ' .title');//頂層節(jié)點名稱
 function TNode_MouseDown(e,Obj){
 if(e.which==3){
 if(Obj.hasClass(ChildNodeClass)){//沒有子節(jié)點才需要有權(quán)限設(shè)置菜單
 MousePostion(e,1);
 with($('#OpLimits_Menu')){
  css('left',Mouse_X);
  css('top',Mouse_Y);
  css('display','block');
 }
 }
 }
 }
 //-------------禁用系統(tǒng)的右鍵功能-----------
 $(document).bind('contextmenu',function(e){ 
 return false; 
 }); 
 var LimitsMenu_Width,LimitsMenu_Height;
 LimitsMenu_Width = $('#OpLimits_Menu').width();
 LimitsMenu_Height = $('#OpLimits_Menu').height();
 var LimitsSetting_Width,LimitsSetting_Height;
 LimitsSetting_Width = $('#OpLimitsSetting').width();
 LimitsSetting_Height = $('#OpLimitsSetting').height();
 TChildNode.mousedown(function(e){
 TNode_MouseDown(e,$(this));
 });
 $(this).mousedown(function(e){
 if(Mouse_X && Mouse_Y){
 MousePostion(e,0);
 var IsInArea = Mouse_X>TMenu_X0 && Mouse_X<TMenu_X0+LimitsMenu_Width && Mouse_Y>TMenu_Y0 && Mouse_Y<TMenu_Y0+LimitsMenu_Height;
 if(e.which==1 && !IsInArea){
  with($('#OpLimits_Menu')){
  css('display','none');
  }
 }
 }
 });
 //-----------------------------------------
 //計算坐標函數(shù)
 MousePostion = function(e,tag){
 mouse = new MouseEvent(e);
 Mouse_X = mouse.x;
 Mouse_Y = mouse.y;
 if(tag==1){
 TMenu_X0 = Mouse_X;
 TMenu_Y0 = Mouse_Y;
 }
 }
 //獲取鼠標坐標函數(shù)
 var MouseEvent = function(e) {
 this.x = e.pageX
 this.y = e.pageY
 }
 //---------------------------------------- 
 with($('#OpLimits_Menu li')){
 mouseover(function(){
 $(this).addClass('onmouse');
 });
 mouseout(function(){
 $(this).removeClass('onmouse');
 });
 click(function(){ 
 with($('#OpLimits_Menu')){
 css('display','none');
 }
 });
 }
});
</script>
</head>
<body>
<div id="TreeList">
 <div class="ParentNode show">
  <div class="title">酷站欣賞</div>
 </div>
 <div class="Row">
  <div class="ChildNode">
  <div class="title">歐美酷站</div>
  </div>
  <div class="ChildNode">
  <div class="title">日韓酷站</div>
  </div>
  <div class="ChildNode">
  <div class="title">國內(nèi)酷站</div>
  </div>
  <div class="ChildNode">
  <div class="title">婚慶攝影</div>
  </div>
  <div class="ChildNode">
  <div class="title">餐飲食品</div>
  </div>
 </div>
</div>
<div id="OpLimits_Menu" style="display:none">
 <h1>權(quán)限設(shè)置</h1>
 <ul>
  <li value="1">查看</li>
  <li value="2">添加</li>
  <li value="3">修改</li>
  <li value="4">刪除</li>
 </ul>
</div>
</body>
</html>

希望本文所述對大家的jquery程序設(shè)計有所幫助。

相關(guān)文章

  • jQuery實現(xiàn)文本展開收縮特效

    jQuery實現(xiàn)文本展開收縮特效

    在網(wǎng)頁上只有一個小區(qū)域,但是說明性的文字又很長,下面這段腳本實現(xiàn)的是長文字的部分顯示,有類似需求的朋友可以參考下哈,希望對你有所幫助
    2015-06-06
  • jquery實現(xiàn)最簡單的滑動菜單效果代碼

    jquery實現(xiàn)最簡單的滑動菜單效果代碼

    這篇文章主要介紹了jquery實現(xiàn)最簡單的滑動菜單效果代碼,涉及jQuery基于鼠標事件操作頁面元素動態(tài)變換的基本技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-09-09
  • jquery 判斷div show的狀態(tài)實例

    jquery 判斷div show的狀態(tài)實例

    下面小編就為大家?guī)硪黄猨query 判斷div show的狀態(tài)實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧,祝大家游戲愉快哦
    2016-12-12
  • zTree jQuery 樹插件的使用(實例講解)

    zTree jQuery 樹插件的使用(實例講解)

    下面小編就為大家?guī)硪黄獄Tree jQuery 樹插件的使用(實例講解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • 原生js和jQuery寫的網(wǎng)頁選項卡特效對比

    原生js和jQuery寫的網(wǎng)頁選項卡特效對比

    本文實例中主要是通過判斷點擊菜單在菜單列表中的索引位置來顯示或隱藏選項區(qū).原生js還有很多種實現(xiàn)方法(藍色理想中搜索),為了與jQ版思路保持一致,本文實例用的是循環(huán)判斷.有需要的小伙伴可以參考下
    2015-04-04
  • jQuery實現(xiàn)仿京東防抖動菜單效果示例

    jQuery實現(xiàn)仿京東防抖動菜單效果示例

    這篇文章主要介紹了jQuery實現(xiàn)仿京東防抖動菜單效果,結(jié)合實例形式分析了jQuery事件響應(yīng)及頁面屬性動態(tài)操作相關(guān)實現(xiàn)技巧,需要的朋友可以參考下
    2018-07-07
  • jQuery中:disabled選擇器用法實例

    jQuery中:disabled選擇器用法實例

    這篇文章主要介紹了jQuery中:disabled選擇器用法,實例分析了:disabled選擇器功能、定義及選取所有禁用的表單元素的技巧,需要的朋友可以參考下
    2015-01-01
  • jquery命令匯總,方便使用jquery的朋友

    jquery命令匯總,方便使用jquery的朋友

    jquery命令匯總,方便使用jquery的朋友,需要的朋友可以收藏下
    2012-06-06
  • jQuery實現(xiàn)表單步驟流程導航代碼分享

    jQuery實現(xiàn)表單步驟流程導航代碼分享

    這篇文章主要介紹了jQuery實現(xiàn)表單步驟流程導航,代碼實現(xiàn)效果簡單精致,推薦給大家,有需要的小伙伴可以參考下。
    2015-08-08
  • Jquery時間驗證和轉(zhuǎn)換工具小例子

    Jquery時間驗證和轉(zhuǎn)換工具小例子

    這篇文章介紹了Jquery時間驗證和轉(zhuǎn)換工具小例子,有需要的朋友可以參考一下
    2013-07-07

最新評論

浦城县| 大名县| 尉犁县| 常熟市| 常德市| 名山县| 碌曲县| 洪洞县| 淮南市| 乌拉特后旗| 泸水县| 梁河县| 京山县| 沈阳市| 江达县| 贞丰县| 韶关市| 旌德县| 新巴尔虎右旗| 垦利县| 青阳县| 西和县| 奈曼旗| 南涧| 新乡县| 阳城县| 永顺县| 石林| 拉萨市| 大石桥市| 习水县| 盘山县| 淅川县| 拜城县| 竹溪县| 略阳县| 光泽县| 孟津县| 双流县| 云龙县| 塔河县|