Creating Drop Down Menu on click CSS

前端 未结 8 863
夕颜
夕颜 2020-11-28 13:48

I\'m required to build a menu with 5 options, upon clicking a certain one a new sub menu is to appear. I have absolutely no idea how to do this.

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 14:27

     $('#open').on('click', function(e) {
       simple_showpopup("popup", e);
     });
    
     function simple_showpopup(id, evt) {
       var _pnl = $("#" + id);
       _pnl.show();
       _pnl.css({
         "left": evt.pageX - ($("#" + id).width() / 2),
         "top": (evt.pageY + 10)
       });
    
       $(document).on("mouseup", function(e) {
         var popup = $("#" + id);
         if (!popup.is(e.target) && popup.has(e.target).length == 0) {
           popup.hide();
           $(this).off(e);
         }
       });
     }
    
     $("#popup").hide();
    .defa-context-panel {
      border: 1px solid black;
      position: absolute;
      min-width: 200px;
      min-height: 150px;
      background-color: #f8f8f8;
      border: solid 1px #f2f2f2;
      border-radius: 10px;
      padding: 5px;
    }
    
           Open    Click here
    
    

提交回复
热议问题