As commented by @Benilson, you can hide div com display: none
:
$('#texto').popover({
html: true,
content: function () {
return $('#teste').html();
}
});
#teste{
display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<button type="button" id ="texto" class="btn btn-lg btn-danger" data-toggle="popover-click" title="Título do popover" >Clique para ver o popover</button>
<div id="teste">
<h1>meu conteudo <strong>ira</strong> aqui</h1>
</div>
Or use a string template to mount HTML, without having to create a DOM node:
$('#texto').popover({
html: true,
content: function () {
var html = `<h1>
meu conteudo <strong>ira</strong> aqui
</h1>`;
return html;
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<button type="button" id ="texto" class="btn btn-lg btn-danger" data-toggle="popover-click" title="Título do popover" >Clique para ver o popover</button>
A simple solution is to keep the div hidden: <div id="test" style="display: None;">.
– Benilson