/Context-menu-using-javascript

In this tutorial we will be creating custom Context menu / Right click menu using HTML, CSS and JavaScript

Primary LanguageCSS

Custom Context / Right click menu using HTML, CSS and JavaScript

In this tutorial we will be learning how to create custom cotext menu using HTML, CSS and JavaScript

Usage

//JavScript Code
//Download this repository for full code

window.addEventListener("contextmenu",function(event){
  event.preventDefault();
  var contextElement = document.getElementById("context-menu");
  contextElement.style.top = event.offsetY + "px";
  contextElement.style.left = event.offsetX + "px";
  contextElement.classList.add("active");
});
window.addEventListener("click",function(){
  document.getElementById("context-menu").classList.remove("active");
});

Subscribe

Please subscribe CodeWithNiranjan

Thank You