Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
399 views
in Technique[技术] by (71.8m points)

javascript - 在悬停时出现Bootstrap Popover / Disappear而不是Click(Make Bootstrap Popover Appear/Disappear on Hover instead of Click)

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.(我正在使用Bootstrap的Popover构建一个网站,我无法弄清楚如何使鼠标悬停而不是点击。)

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.(文档说明可以使用data属性或jquery。) I'd much rather do it with jquery since I have multiple popovers.(因为我有多个弹出窗口,所以我宁愿用jquery做这件事。)   ask by Muhambi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Set the trigger option of the popover to hover instead of click , which is the default one.(将弹出窗口的trigger选项设置为hover而不是click ,这是默认值 。)

This can be done using either data-* attributes in the markup:(这可以使用标记中的data-*属性来完成:)

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

Or with an initialization option:(或者使用初始化选项:)

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

Here's a DEMO .(这是一个演示 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...