自动隐藏引导弹出窗口 [英] Auto hide bootstrap popover

查看:81
本文介绍了自动隐藏引导弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在几秒钟后自动隐藏Bootstrap popovers。
当用户将鼠标悬停在控件上时,必须显示弹出窗口,但如果用户未移动鼠标指针,则必须在几秒钟后自动隐藏此弹出框。

I want to hide automatically the Bootstrap popovers after a few seconds. When the user hovers over a control, the popover must be displayed, but if the user doesn't move the mouse pointer, this popover must be hidden automatically after few seconds.

这很重要,因为在手机或平板电脑上,当用户点击一个控件时,会显示弹出窗口,当用户输入内容时,焦点会保留在同一控件上,弹出窗口会阻碍它。

That is important because in a mobile phone or tablet when the user taps a control, the popover is displayed, and the focus remains on the same control while the user types something, with the popover hindering it.

推荐答案

在寻求帮助之前,你真的应该试一试并发布你的代码。这可行,但可能有一个更有效的方法:

You really should give it a try and post your code before asking for help. This works, though there may be a more efficient method:

$('.pop').popover().click(function () {
    setTimeout(function () {
        $('.pop').popover('hide');
    }, 2000);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<span class="pop" data-original-title="My popover" data-content="Isn't it great?">Click me</span>

http://jsfiddle.net/isherwood/Bqq7C/27/

这篇关于自动隐藏引导弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆