最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML inside bootstrap 5 tooltip - Stack Overflow

programmeradmin2浏览0评论

Following the documentation, I need to display some HTML inside a bootstrap 5 tooltip.

However, copy pasta from the doc does not give the expected output.

<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
                                    Tooltip with HTML
                                  </button>

Here is a jsfiddle.

Instead of displaying parsed HTML, HTML is parse as text.

How can I display content as HTML instead of text ?

Following the documentation, I need to display some HTML inside a bootstrap 5 tooltip.

However, copy pasta from the doc does not give the expected output.

<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
                                    Tooltip with HTML
                                  </button>

Here is a jsfiddle.

Instead of displaying parsed HTML, HTML is parse as text.

How can I display content as HTML instead of text ?

Share Improve this question asked Sep 3, 2021 at 8:59 Itération 122442Itération 122442 2,9823 gold badges41 silver badges91 bronze badges 1
  • 1 You are using Bootstrap5, yet you are working off of the documentation for version 4. The attribute enabling HTML content needs to be data-bs-html="true" – C3roe Commented Sep 3, 2021 at 9:10
Add a ment  | 

1 Answer 1

Reset to default 6

In Bootstrap v5.0 you should use data-bs-html="true".

<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
  Tooltip with HTML
</button>

Your JSFiddle.

发布评论

评论列表(0)

  1. 暂无评论