为什么右键菜单插件的contextmenu的保存和退出的div一开始没有显示在页面中,CSS也没看到display:none,求赐教???

来源:2-7 右键菜单插件——contextmenu

慕粉4345620

2017-03-15 21:10

html 代码

<!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://www.imooc.com/data/jquery.contextmenu.css" rel="stylesheet" type="text/css" />

        <link href="style.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript" src="http://www.imooc.com/data/jquery-1.8.2.min.js"></script>

        <script src="http://www.imooc.com/data/jquery.contextmenu.js" type="text/javascript"></script>

    </head>

    

    <body>

        <div id="divtest">

            <div class="title"><span class="fl">点击右键</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://img.mukewang.com/52e4b34b0001bb6d00160016.jpg" alt="" />保存</li>

                    <li id="Li4"><img src="http://img.mukewang.com/52e4b3680001424900160016.jpg" alt="" />退出</li>

                </ul>

            </div>

        </div>

        <script type="text/javascript">

            $(function () {

                $("#divtest").contextMenu('sysMenu',

                  { bindings:

                     {

                         'Li3': function (Item) {

                             $(".tip").show().html("您点击了“保存”项");

                         },

                         'Li4': function (Item) {

                             $(".tip").show().html("您点击了“退出”项");

                         }

                     }

                  });

            });

        </script>

        </body>

</html>

加粗部分没有显示出来

下面是CSS

#divtest

{

    width: 282px;

}

#divtest .title

{

    padding: 8px;

    background-color: Blue;

    color: #fff;

    height: 23px;

    line-height: 23px;

    font-size: 15px;

    font-weight: bold;

}

#divtest .content

{

    padding: 8px 0px;

    background-color: #fff;

    font-size: 13px;

}

#divtest .content .tip

{

    text-align: center;

    border: solid 1px #ccc;

    background-color: #eee;

    margin: 20px 0px;

    padding: 8px;

    display: none;

}

.fl

{

    float: left;

}

.fr

{

    float: right;

}


写回答 关注

2回答

  • qq_叔山无趾_0
    2017-03-17 09:52:29
    已采纳

    <head>里边引用了一个这个css<link href="http://www.imooc.com/data/jquery.contextmenu.css" rel="stylesheet" type="text/css" /> 内容为

    .contextMenu {display:none}
    ul li {font-size:9pt}

    qq_晚安_...

    把<link href="http://www.imooc.com/data/jquery.contextmenu.css" rel="stylesheet" type="text/css" />删除。效果没变

    2017-08-11 14:46:52

    共 3 条回复 >

  • 触动聆听
    2017-11-04 21:37:55

    此插件会自动隐藏id="contextMenu"的元素

    触动聆听

    是class,不是id

    2017-11-04 21:40:32

    共 1 条回复 >

jQuery基础(五)一Ajax应用与常用插件

如何用jquery实现ajax应用,加入学习,有效提高前端开发速度

69095 学习 · 400 问题

查看课程

相似问题