为什么addEventListener属性不起作用

时间:2020-09-21 02:24:32

标签: javascript html css addeventlistener

这是我的代码

const closeBtn = document.querySelector('.current button')

closeBtn.addEventListener('mouseover', e => {
  closeBtn.parentElement.style.display='none'
})
<div class="slide current">
            <div class="content">
                <button class="closeBtn">&times;</button>
                <h1>Orchidaceae</h1>
                <p>
                    There are between 22,000 and 26,000 species in 880 genera. They make up between 6–11% of all seed
                    plants. Orchids can be found in almost every country in the world except for Antarctica.
                </p>
            </div>
        </div>

您能检查出什么问题吗?

我试图单击当前幻灯片上的关闭按钮以隐藏内容,但是它没有显示任何错误,也没有任何线索!

0 个答案:

没有答案