カスタムコンテキストメニューが必要なので、それを使用addEventListener
しますが、div2ではなくdiv1に配置したいのですが、同じリスナーを追加せずにそれを行うにはどうすればよいですか?stopPropagation()
<html>
<head>
</head>
<body>
<div id="div1" style="background-color:green;border:3px solid black;width:300px;height:300px;margin:auto;">
<div id="div2" style="background-color:yellow;border:3px solid black;width:100px;height:100px;margin:auto;margin-top:-50px;">
some text
</div>
</div>
<script>
document.getElementById('div1').addEventListener('contextmenu', function(e)
{
console.log('contextmenu');
});
</script>
</body>
</html>