javascript - 将弹出框放在 noUiSlider handle 上

标签 javascript jquery twitter-bootstrap-3 nouislider

我正在研究使用 noUislider 作为 slider 。我想做的一件事是,将鼠标悬停在 handle 上时,您可以看到一个弹出窗口,单击它后,弹出窗口内将发生另一个操作。如何定位 slider 内部的特定句柄 noUi-handle noUi-handle-lower 以触发弹出窗口?

澄清一下:该 slider 的下部 handle 是 slider 中的嵌入式子项。

<div id="slider1" style="width: 400px; margin: 0px auto 30px;" class="noUi-target noUi-ltr noUi-horizontal" data-placement="right" data-toggle="popover1" data-original-title="" > <div class="noUi-base"><div class="noUi-connects"></div><div class="noUi-origin" style="transform: translate(-100%, 0px); z-index: 5;">
<div class="noUi-handle noUi-handle-lower" data-handle="0" tabindex="0" role="slider" aria-orientation="horizontal" aria-valuemin="0.0" aria-valuemax="100.0" aria-valuenow="0.0" aria-valuetext="0.00"></div></div>
<div class="noUi-origin" style="transform: translate(0%, 0px); z-index: 4;"><div class="noUi-handle noUi-handle-upper" data-handle="1" tabindex="0" role="slider" aria-orientation="horizontal" aria-valuemin="0.0" aria-valuemax="100.0" aria-valuenow="100.0" aria-valuetext="100.00"></div></div></div></div>

$('#slider1 .noUi-handle noUi-handle-lower').popover({trigger: "manual", container: 'body', title: "Hello", content: "Test"})
    .on('mouseenter', function() { enterShow('slider1')})
    .on('mouseleave', function() { exitHide('slider1')})
    .on('click', function() { clickToggle('sliderx1')});

最佳答案

类似这样的事情应该可以做到:

// target the particular handle    
const handle = document.querySelector('.noUi-handle noUi-handle-lower');

handle.onmouseenter = function () {
    // code to insert popover HTML goes here
}

handle.onmouseleave = function () {
    // code to remove popover HTML goes here
}

我不会为你做“popover”HTML,因为那实际上可以是任何东西。我建议使用insertAdjacentHTML为了这。祝你好运。

关于javascript - 将弹出框放在 noUiSlider handle 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52541396/

相关文章:

javascript - 如何在悬停另一个 HTML 元素时创建平滑缩放并显示叠加层?

javascript - 适用于 JavaScript/Google v8 的持久性框架

css - Bootstrap : Empty spaces on layout due text size

javascript - 检查整个元素何时在 View 中

javascript - 如何在 Bootstrap 的选项卡中显示链接?

php - 如何调整菜单图标的尺寸

javascript - javascript中动态添加字段并将数据保存到mysql

javascript - Extjs : url in store

javascript - 为每个 <li> 更改不同的类

javascript - 滚动图像时如何移动图像上添加的图钉