javascript - 为什么 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">×</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>
你能检查一下有什么问题吗?
我正在尝试单击当前幻灯片上的关闭按钮以隐藏内容,但它没有显示任何错误,也没有任何线索!
解决方案
推荐阅读
- matlab - 迭代模拟的严重性能问题
- ssl - kafka 中的 SSL 错误:入站在接收对等方的 close_notify 之前关闭
- ios - iOS - NSTimeZone 的 3 字母时区缩写
- c++ - C++:当我使用文件描述符从日志文件中读取时,识别日志文件何时被移动/重命名/删除
- ios - CAGradientLayer:其他 UIObjects 没有出现
- javascript - 从数组中获取字符串?
- windows - Git 一次克隆一点点或其他解决方案
- matlab - 从 MATLAB 中的结构体字段的实例开始构建矩阵
- reactjs - 为 iOS 运行任何 React-Native 项目都会导致“无法解析模块”错误
- sql - 基于三个不同的分类变量创建相似的样本