简体   繁体   English

HTML图像标记无法呈现正确分配给标题属性的表格

[英]HTML Image tag doesn’t render table properly assigned to title attribute

I am trying to assign table to image's title property using javascript but when I hover over the image it doesn't render a table instead it displays the table as text. 我正在尝试使用JavaScript将表格分配给图片的title属性,但是当我将鼠标悬停在图片上时,它不会呈现表格,而是将表格显示为文本。

function FormatAssessorInfo(P1, P2)
{           
    var ToolTipTable = "<table width='200px' border='0' cellspacing='0' cellpadding='2'> <tbody> <tr> <td> Phone: </td> <td> " + P1 + " </td> <td> Cell: </td> <td> " + P2 + " </td> </tr> </tbody> </table>";
    return '<img src="/files/404048/93171/Info-32.png" height="15" width="15" title="' + ToolTipTable + '" style=""/>'; 
}

在此处输入图片说明

This is not possible with what you're trying. 您尝试的操作无法做到这一点。 You may want to use some tooltip plugin for that. 您可能要使用一些tooltip插件。 Like jQuery tooltips . jQuery tooltips一样。

From MDN : MDN

The title attribute contains text representing advisory information, related to the element it belongs to. 标题属性包含表示咨询信息的文本 ,与它所属的元素有关。

Since it's text, and not html, it not gets interpreted by the browser. 由于它是文本,而不是html,因此不会被浏览器解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM