以下脚本功能似乎只有在工具提示的一个实例可用时才起作用。我也没有收到任何控制台错误。您有什么想法吗?
使用 Bootstrap 4
使用 Bootstrap 4
<!-- Tooltip link 1 -->
<p><span class="tip" data-tip="my-tip1">Load Tip 1</span></p>
<!-- Tooltip link 2 -->
<p><span class="tip" data-tip="my-tip2">Load tip 2</span></p>
<!-- Tooltip content 1 -->
<div id="my-tip1" class="tip-content hidden">
<h2>Content Number One</h2>
<p>This is my tip content One</p>
</div>
<!-- Tooltip content 2 -->
<div id="my-tip2" class="tip-content hidden">
<h2>Content number Two</h2>
<p>This is my tip content Two </p>
</div>
JavaScript:
<script type="text/javascript">
$(document).ready(function () {
// Tooltips
$('.tip').each(function () {
$(this).tooltip(
{
html: true,
title: $('#' + $(this).data('tip')).html()
});
});
});
</script>