作為<li>元素的”保存“”退出“怎么不顯示在頁面上,而是通過右鍵才能顯示?
<body>
? ? ? ? <div id="divtest">
? ? ? ? ? ? <div class="title"><span class="fl">點(diǎn)擊右鍵</span></div>
? ? ? ? ? ? <div class="content">
? ? ? ? ? ? ? ? <input id="btnSubmit" type="button" value="提交" />
? ? ? ? ? ? ? ? <div class="tip"></div>
? ? ? ? ? ? </div>
? ? ? ? ? ? <div class="contextMenu" id="sysMenu">
? ? ? ? ? ? ? ? <ul>
? ? ? ? ? ? ? ? ? ? <li id="Li3"><img src="http://img1.sycdn.imooc.com//52e4b34b0001bb6d00160016.jpg" alt="" />保存</li>
? ? ? ? ? ? ? ? ? ? <li id="Li4"><img src="http://img1.sycdn.imooc.com//52e4b3680001424900160016.jpg" alt="" />退出</li>
? ? ? ? ? ? ? ? </ul>
? ? ? ? ? ? </div>
? ? ? ? </div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? $("#divtest").contextMenu("sysMenu",
? ? ? ? ? ? ? ? ? { bindings:
? ? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ? ?'Li3': function (Item) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(".tip").show().html("您點(diǎn)擊了“保存”項(xiàng)");
? ? ? ? ? ? ? ? ? ? ? ? ?},
? ? ? ? ? ? ? ? ? ? ? ? ?'Li4': function (Item) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(".tip").show().html("您點(diǎn)擊了“退出”項(xiàng)");
? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? });
2017-03-17
看清題目,它就是個右鍵點(diǎn)擊顯示自定義菜單的插件!
2017-07-25
<!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>
? ? ? ? <title>右鍵菜單插件</title>
? ? ? ? <link href="http://idcbgp.cn/data/jquery.contextmenu.css" rel="stylesheet" type="text/css" />
? ? ? ? <link href="style.css" rel="stylesheet" type="text/css" />
? ? ? ? <script type="text/javascript" src="http://idcbgp.cn/data/jquery-1.8.2.min.js"></script>
? ? ? ? <script src="http://idcbgp.cn/data/jquery.contextmenu.js" type="text/javascript"></script>
? ? </head>
? ??
? ? <body>
? ? ? ? <div id="divtest">
? ? ? ? ? ? <div class="title"><span class="fl">點(diǎn)擊右鍵</span></div>
? ? ? ? ? ? <div class="content">
? ? ? ? ? ? ? ? <input id="btnSubmit" type="button" value="提交" />
? ? ? ? ? ? ? ? <div class="tip"></div>
? ? ? ? ? ? </div>
? ? ? ? ? ? <div class="contextMenu" id="sysMenu">
? ? ? ? ? ? ? ? <ul>
? ? ? ? ? ? ? ? ? ? <li id="Li3"><img src="http://img1.sycdn.imooc.com//52e4b34b0001bb6d00160016.jpg" alt="" />保存</li>
? ? ? ? ? ? ? ? ? ? <li id="Li4"><img src="http://img1.sycdn.imooc.com//52e4b3680001424900160016.jpg" alt="" />退出</li>
? ? ? ? ? ? ? ? </ul>
? ? ? ? ? ? </div>
? ? ? ? </div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? $("#btnSubmit").contextMenu('sysMenu',
? ? ? ? ? ? ? ? ? { bindings:
? ? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ? ?'Li3': function (Item) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(".tip").show().html("您點(diǎn)擊了“保存”項(xiàng)");
? ? ? ? ? ? ? ? ? ? ? ? ?},
? ? ? ? ? ? ? ? ? ? ? ? ?'Li4': function (Item) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?$(".tip").show().html("您點(diǎn)擊了“退出”項(xiàng)");
? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? });
? ? ? ? </script>
? ? </body>
</html>
為什么沒效果啊
2017-06-20
自己實(shí)現(xiàn)可以綁定鼠標(biāo)點(diǎn)擊事件,如果為右鍵點(diǎn)擊,顯示該li、、、
2017-04-10
另一個問答解釋 了,css里設(shè)置了#contextMenu{display:none;}