Right, that’s because you’re using trigger
as hover
.
Take a look at the Popover documentation https://getbootstrap.com/docs/4.0/components/popovers
I did a very simple workaround here, if you want to follow it, from an improved code, abstraction to a function and etc.
$(() => {
const popover = $('#myPopover');
popover.popover({
html: true,
placement: "bottom",
trigger: "manual",
title: '',
content: 'Clique <a href="#" data-popover="myPopover" class="close-popover">aqui</a> para voltar'
});
popover.on('mouseover', () => popover.popover('show') );
popover.on('shown.bs.popover', (event) => {
const id = popover.attr('id');
$(`[data-popover=${id}].close-popover`).on('click', () => {
popover.popover('hide');
});
});
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<div class="container">
<button
id="myPopover"
type="button"
class="btn btn-secondary">
Popover
</button>
</div>