使 Bootstrap Popover 在悬停而不是单击时出现/消失 [英] Make Bootstrap Popover Appear/Disappear on Hover instead of Click

查看:35
本文介绍了使 Bootstrap Popover 在悬停而不是单击时出现/消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Bootstrap 的 Popover 构建一个网站,但我不知道如何制作弹出窗口出现在悬停而不是点击上.

I'm building a website with Bootstrap's Popover and I can't figure out how to make the popover appear on hover instead of click.

我想要做的就是当有人将鼠标悬停在链接上而不是点击它时出现一个弹出框,并且当他们离开时弹出框消失.文档说可以使用 data 属性或 jquery.我更愿意用 jquery 来做,因为我有多个弹出框.

All I want to do is have a popover appear when someone hovers over a link instead of clicking on it and for the popover to disappear when they move away. The documentation says it's possible using either the data attribute or jquery. I'd much rather do it with jquery since I have multiple popovers.

推荐答案

将弹出框的 trigger 选项设置为 hover 而不是 <代码>点击,这是默认一个.

Set the trigger option of the popover to hover instead of click, which is the default one.

这可以使用标记中的 data-* 属性来完成:

This can be done using either data-* attributes in the markup:

<a id="popover" data-trigger="hover">Popover</a>

或者使用初始化选项:

$("#popover").popover({ trigger: "hover" });

这是一个演示.

Here's a DEMO.

这篇关于使 Bootstrap Popover 在悬停而不是单击时出现/消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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