0

Bootstrap 4 Advanced Right click menu

$('.jumbotron').on('contextmenu', function(e) {
  var top = e.pageY - 10;
  var left = e.pageX - 90;
  $("#context-menu").css({
    display: "block",
    top: top,
    left: left
  }).addClass("show");
  return false; //blocks default Webbrowser right click menu
}).on("click", function() {
  $("#context-menu").removeClass("show").hide();
});

$("#context-menu a").on("click", function() {
  $(this).parent().removeClass("show").hide();
});
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="container">
  <div class="row my-3">
    <div class="col">
      <div class="jumbotron">
        <h1>Right click menu for Bootstrap 4 - Advanced Components</h1>
        <p class="lead">by djibe.</p>
        <h2>
        Demo
        </h2>
          <p>Just right click in this Jumbotron to test.</p>
        <div class="dropdown-menu dropdown-menu-sm" id="context-menu">
          <a class="dropdown-item" href="#">Action</a>
          <a class="dropdown-item" href="#">Another action</a>
          <a class="dropdown-item" href="#">Something else here</a>
        </div>
      </div>
    </div>
  </div>
</div>
RUN
add comment
Suggest a different solution or add another example