我在浏览 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获取更多信息。
例如,"<" is "<" (less-than sign, 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 是为了显示一张图片和 ant 之间的文字 strong... 是 strong :-)
关于javascript - 这些符号在html中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30069009/