javascript - 在 bootstrap 的下拉菜单中将鼠标悬停在鼠标上时保持父项处于选中状态

标签 javascript jquery css

我想做的是保留 <a>在我将鼠标悬停在下拉菜单上时选择: enter image description here

我尝试了 closest选择器但不起作用:

$('.dropdown-menu', this).stop().fadeIn("fast").closest("a").css("background-color", "#eee");

这是我的 jsfiddle 。谢谢。

最佳答案

我建议使用 CSS:

li:hover {
    background-color: #eee;
}

JS Fiddle demo .

显然根据需要调整选择器的复杂性。

关于javascript - 在 bootstrap 的下拉菜单中将鼠标悬停在鼠标上时保持父项处于选中状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27111929/

相关文章:

javascript - 使用 Twilio 从 IP 摄像机 RTSP 流式传输视频

javascript - 删除导致页面刷新问题的查询参数

jQuery PrettyPhoto 问题

Javascript - 更改没有值的输入元素的内容

javascript - 不会打印出来

jquery - 进行响应测试后下拉菜单显示为打开状态

javascript - jQuery Cycle 插件 : centering background images when browser is resized

javascript - 如何在 Javascript 中将文本文件中的段落作为单个字符串读取?

jquery - 在 date_popup drupal 中突出显示当前周

html - GTM : Click trigger for button with many nested classes