我在浏览
jquery工具提示时发现了这段代码.请建议我们为什么使用某些代码,这是什么意思?
<pre class="prettyprint">
<head>
<script>
$(document).ready(function() {
$('.tooltip').tooltipster({
contentAsHTML: true
});
});
</script>
</head>
<body>
<div 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 div has a tooltip with HTML when you hover over it!
</div>
</body></pre>
最佳答案 您输入的代码是html编码的,这意味着使用html特殊字符:
<script>
$(document).ready(function() {
$('.tooltip').tooltipster({
contentAsHTML: true
});
});
</script>
</head>
<body>
<div class="tooltip" title="<img src=my-image.png /> <strong> This text is in bold case!</strong>">
This div has a tooltip with HTML when you hover over it!
</div>
</body></pre>
ISO-8859-1是HTML 4.01中的默认字符,请参阅list of XML and HTML character以获取更多信息.
例如,“& lt;”是“<” (小于号,U 003C) 当用户将鼠标放在包含文本的div上时,您尝试理解的代码会创建工具提示
This div has a tooltip with HTML when you hover over it!
toolpit的内容位于title标签之间,所以
<img src=my-image.png /> <strong> This text is in bold case!</strong>
img是显示图片蚂蚁之间强烈的文字…很强:-)