亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

詳解bootstrap用dropdown-menu實(shí)現(xiàn)上下文菜單

 更新時(shí)間:2017年09月22日 09:41:24   作者:lynnlysh  
這篇文章主要介紹了詳解bootstrap用dropdown-menu實(shí)現(xiàn)上下文菜單的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下

詳解bootstrap用dropdown-menu實(shí)現(xiàn)上下文菜單

寫在前面:

所謂上下文菜單,它與一般菜單的區(qū)別在于:

通過右鍵觸發(fā)顯示在鼠標(biāo)右鍵點(diǎn)擊處

鼠標(biāo)在別處點(diǎn)擊后,該菜單消失

實(shí)現(xiàn)方法:

在html中定義一個(gè)普通的沒有觸發(fā)條件的dropdown-menu,然后寫這個(gè)menu的父容器的監(jiān)聽即可實(shí)現(xiàn)。

代碼:

<div id="settingInGraph"> 
              <ul class="dropdown-menu" role="menu" 
                aria-labelledby="dropdownMenu" id="contextMenu"> 
                <li><a tabindex="-1" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >任務(wù)指派</a></li> 
                <li><a tabindex="-1" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >任務(wù)監(jiān)聽</a></li> 
                <li><a tabindex="-1" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >任務(wù)表單</a></li> 
                <li class="divider"></li> 
                <li><a tabindex="-1" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >...</a></li> 
              </ul> 
            </div> 
$("#settingInGraph").mousedown(function(e) { 
if (3 == e.which) { 
     document.oncontextmenu = function() {return false;} 
     $("#contextMenu").hide(); 
     $("#contextMenu").attr("style","display: block; position: fixed; top:" 
     + e.pageY 
     + "px; left:" 
     + e.pageX 
     + "px; width: 180px;"); 
     $("#contextMenu").show(); 
     } 
}); 
$("#settingInGraph").click(function(e) { 
$("#contextMenu").hide();              }); 

如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論