Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 794 Bytes

README.md

File metadata and controls

27 lines (20 loc) · 794 Bytes

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