JSFiddle - React, Tailwind, and code Playground

HTML

<div id="context-menu">                        
    <ul>                        
      <li>Item1</li>                      
      <li>Item2</li>
      <li>Item3</li>
    </ul>
</div>
<div id="op">Right click anywhere!</div>

CSS

#context-menu {
    display: none;        
    position: fixed;       
    border: 1px solid #ddd;
    background: white;
    box-shadow: 2px 2px 1px grey;  
}
#context-menu ul {
    list-style: none;      
    padding: 0;
    margin: 0;
}
#context-menu li {
    width:150px;
    padding: 5px 8px;
}
#context-menu li:hover {
    background:#eaeaea;
    cursor:pointer;
}

JavaScript

function startFocusOut() {
    $(document).on("click", function () {   
        $("#context-menu").fadeOut(20);              // To hide the context menu
        $(document).off("click");           
    });
}
$(function(){
    $(document).bind("contextmenu", function (e) {
        e.preventDefault();            // To prevent the default context menu.
        $("#context-menu").css("left", e.pageX);   // position with cursor
        $("#context-menu").css("top", e.pageY);    
        $("#context-menu").fadeIn(20, startFocusOut()); // show the menu
    });    
    $("#context-menu li").click(function () {
        $("#op").text("You have selected " + $(this).text());  // Performing the selected function.
    });
});