Bootstrap 5 Dropdown组件扩展hover事件 精简版
本帖最后由 逆风天 于 2024-1-30 16:01 编辑Bootstrap 5 Dropdown组件扩展hover事件
经过研究,有更精简简单的扩展办法,如下:
const getDropdown = document.querySelectorAll('');
if (getDropdown.length > 0) {
getDropdown.forEach(function (Item) {
let ThisEl = new bootstrap.Dropdown(Item);
Item.addEventListener('mouseenter', function () {
ThisEl.show();
})
Item.parentNode.addEventListener('mouseleave', function () {
setTimeout(() => {
ThisEl.hide();
}, 300);
})
})
}
要求不高的话,可以使用这个方法
# 点我查看 #
页:
[1]