html - 当用户关注弹出内容时,引导弹出内容不应隐藏
问题描述
我已经实现了在按钮悬停时显示弹出框。当用户关注内容时,弹出内容被隐藏。我已经实现了下面的代码。我不应该在用户关注内容时隐藏弹出内容,任何人都可以建议
$(function() {
$('[data-toggle="popover"]').popover({
trigger: 'hover focus',
placement: 'bottom',
content: "And here's some amazing content. It's very engaging. Right?",
title: "Popover title",
html: true,
template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'
})
})
谢谢
解决方案
<html>
<head>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</head>
<body>
<a class="btn btn-sm btn-dark notice-pop" data-trigger="click" data-hideclickout="true" href="javascript:;">Test Button</a>
<script>
$('.notice-pop').popover({
content:"Some Popover Content",
});
$('body').on('click', function (e) {
$('[data-hideclickout="true"][aria-describedby]').each(function () {
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
</script>
</body>
</html>
还有许多其他配置可用。检查文档。
data-hideclickout="true
我在外部单击时要隐藏的元素上添加了一个自定义选项。
推荐阅读
- c# - 如何在调用 IdentityReference 值时给出 If 条件
- javascript - UIkit.toggle() 编程使用切换自身
- perl - Perl 脚本在路由器上设置 snmp 设置
- html - 我需要在刀片文件中的表列上迭代一个数组
- node.js - 我们可以在 AWS Elastic beanstalk 上分别实现前端和后端吗?
- node.js - POST 请求返回 422(无法处理的实体)(MERN)
- javascript - Babel 不允许没有 .js 文件扩展名的导入
- android - 添加 ConstraintLayout 后工具栏不可见
- list - Prolog - 如何返回每个元素只出现一次的列表?
- android - 如何在 mp 图表 android 中管理标记视图偏移