📜  html 上下文菜单 - Html 代码示例

📅  最后修改于: 2022-03-11 14:53:09.933000             🧑  作者: Mango

代码示例1
oncontextmenu = (e) => {
  e.preventDefault()
  let menu = document.createElement("div")
  menu.id = "ctxmenu"
  menu.style = `top:${e.pageY-5}px;left:${e.pageX-5}px`
  menu.onmouseleave = () => ctxmenu.outerHTML = ''
  menu.innerHTML = "

Option1

Option2

Option3

Option4

Upvote

" document.body.appendChild(menu) }