简体   繁体   中英

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.

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. Like jQuery tooltips .

From 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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