简体   繁体   English

引导工具提示不适用于鼠标悬停

[英]bootstrap tooltip not working on mouse hover

I am trying to do to Bootstrap tooltip on mouse hover on an input field of a form but it's not working. 我正在尝试在窗体的输入字段上将鼠标悬停在Bootstrap工具提示上,但无法正常工作。 If you click on the input field, it shows the tooltip. 如果单击输入字段,则会显示工具提示。 However, I want it show on mouse hover and hide after 5 seconds. 但是,我希望它在鼠标悬停时显示并在5秒后隐藏。 Here is the jsfiddle . 这是jsfiddle This is the Javascript code. 这是Javascript代码。

$(function() {
    $("#number").popover({
        title: 'Enter Mobile Number', 
        content: "Please enter 10 digit mobile number prefixed by country code eg +911234567890"
    });  
});

You need to provide attribute data-trigger : 您需要提供属性data-trigger

data-trigger="hover"

Try something like this: FIDDLE 尝试这样的事情: FIDDLE

<input type="text" name="toNumber" id="number" maxlength="13" placeholder="Enter 10 digits number to send" value="+917676462182" rel="popover" data-trigger="hover"/>

To make the popover work on hover, you have to use the trigger: 'hover' method available to the popover. 要使悬停窗口上的弹出窗口有效,您必须使用trigger: 'hover'窗口可用的trigger: 'hover'方法。 You can also add a delay by adding the delay attribute. 您还可以通过添加delay属性来添加delay For example: 例如:

$(function () { 
    $("#number").popover({
        title: 'Enter Mobile Number', 
        content: "Please enter 10 digit mobile number prefixed by country code eg +911234567890",
        trigger: 'hover',
        delay: {show: 0, hide: 3000}
    });  
});

This will show your popover on hover on #number as well as add delay. 这将显示你的上悬停酥料饼#number以及增加延迟。 See my updated jsFiddle as well. 也请参阅我更新的jsFiddle For a full description of the properties, visit the Bootstrap docs on popover . 有关属性的完整说明,请访问popover上的Bootstrap文档

Note that in the jsFiddle, it obscures part of the top of the popover. 请注意,在jsFiddle中,它遮盖了Popover顶部的一部分。 If the input is moved further down the page, the popover will display correctly. 如果将输入进一步移至页面下,则弹出窗口将正确显示。

Try to use trigger:'hover' like, 尝试使用触发器:“悬停”之类的方法,

$(function () {
    $("#number").popover({
        title: 'Enter Mobile Number',
        content: "Please enter 10 digit mobile number prefixed by country code eg +911234567890",
        trigger:'hover'
    });
});

Read popover 阅读弹出框

Demo 演示版

Just select your element, then call popover with hover 只需选择您的元素,然后将鼠标悬停调用popover

<a data-toggle="popover" data-placement="right" data-content="Your Content">Mouse Over Here</a>

$("[data-toggle=popover]").popover({trigger:"hover"});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM