HTML+CSS3+JS 实现的下拉菜单
// Dropdown Menu var dropdown = document.querySelectorAll('.dropdown'); var dropdownArray = Array.prototype.slice.call(dropdown,0); dropdownArray.forEach(function(el){ var button = el.querySelector('a[data-toggle="dropdown"]'), menu = el.querySelector('.dropdown-menu'), arrow = button.querySelector('i.icon-arrow'); button.onclick = function(event) { if(!menu.hasClass('show')) { menu.classList.add('show'); menu.classList.remove('hide'); arrow.classList.add('open'); arrow.classList.remove('close'); event.preventDefault(); } else { menu.classList.remove('show'); menu.classList.add('hide'); arrow.classList.remove('open'); arrow.classList.add('close'); event.preventDefault(); } }; }) Element.prototype.hasClass = function(className) { return this.className && new RegExp("(^|s)" + className + "(s|$)").test(this.className); }; (编辑:长春站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 解决display:flex属性 justify-content: space-between换行
- Gitlab CI 在 Kubernetes 里的 Docker 缓存
- 建议重庆加大集成电路设计领域的结构
- Firefox和IE通用的三则网站重构实用技巧
- .net – Windows操作系统和内存管理 – 应用程序最小化后会
- Win11开发版22458.1000升级 包含了多项改进和Bug修复
- 2020年Fabless供应商占据全球IC销售额的32.8%,再创辉煌!
- 分析 Vue 中的 computed 和 watch 的差别
- 谈谈 Tomcat 请求处理流程
- 数据中心运维管理培训新模式二------ 经验萃取技术的应用