【问题标题】:Tooltipster html content工具提示器 html 内容
【发布时间】:2015-09-13 23:34:09
【问题描述】:

我不知道是什么原因,但在 tooltipster 中,html 内容不会显示。我对 html 进行了编码,在脚本中添加了选项,但仍然是一个字符串。

$(document).ready(function() {
  $('.tooltip').tooltipster({
    contentAsHTML: true,
    interactive: true,
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://iamceege.github.io/tooltipster/js/jquery.tooltipster.js"></script>
<link rel="stylesheet" href="http://iamceege.github.io/tooltipster/css/tooltipster.css">
<span title="&amp;lt;img src=&amp;quot;my-image.png&amp;quot; /&amp;gt; &amp;lt;strong&amp;gt; This text is in bold case !&amp;lt;/strong&amp;gt;" class="tooltip">Why is this not working</span>

【问题讨论】:

标签: javascript jquery html tooltipster


【解决方案1】:

您的 title 属性有一堆 &amp;amp; 实例,而它应该只是 &amp;

例如,您有:

&amp;lt;img src=&amp;quot;my-image.png&amp;quot; /&amp;gt;

什么时候应该:

&lt;img src=&quot;my-image.png&quot; /&gt;

我不确定你是如何生成标题属性的,看起来你可能已经两次转义了字符串。


工作sn-p:

$(document).ready(function() {
  $('.tooltip').tooltipster({
    contentAsHTML: true,
    interactive: true,
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://iamceege.github.io/tooltipster/js/jquery.tooltipster.js"></script>
<link rel="stylesheet" href="http://iamceege.github.io/tooltipster/css/tooltipster.css">
<span class="tooltip" title="&lt;img src=&quot;my-image.png&quot; /&gt; &lt;strong&gt; This text is in bold case !&lt;/strong&gt;">This is working</span>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多