Home  >  Q&A  >  body text

javascript - Off and mask click!

Add a click event to the mask on the left. After clicking, the area on the right will be retracted.
But the event is added to the mask, so if you click on the area on the right, it will be retracted.
What I want The effect is to only click on the black and transparent area on the left, and the event bubbles up. I have used capture, but it doesn’t work.
Please explain it to an expert

过去多啦不再A梦过去多啦不再A梦2683 days ago587

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-19 10:24:09

    遮罩.addEventListener('click', function(e) {
        if (e.target === 遮罩) {
            区域收起
        }
    })

    reply
    0
  • Cancelreply