最初,我创建了一个 jquery 工具提示文本,如下所示:
function setToolTipText(elemId, content) {
$('#' + elemId).tooltip({
content: content,
show: 'fade',
hide: 'explode',
position: {
my: 'left center',
at: 'right+10 center',
collision: 'flipfit'
}
});
}
后来,我使用以下代码更改了具体元素的工具提示文本:
var indent = '     ';
var content = '<div style="display: inline-block;">' +
'<p style="white-space: nowrap; color: #FF8000; font-size: 8pt; font-family: Verdana,Geneva,Arial,Helvetica,sans-serif;">' +
'<b>Name:</b> ' + elem.Name + '<br />' +
'<b>IP:</b> ' + elem.IP + '<br /><br />' +
'<b>Ping to ' + elem.IP + ' with 32 bytes of data:</b><br />' +
(data.responseStatus01 ? 'Reply from ' + elem.IP + ': bytes=32 time=' + data.rtt01 + ' TTL=' + data.ttl01 : data.responseMessage01) + '<br />' +
(data.responseStatus02 ? 'Reply from ' + elem.IP + ': bytes=32 time=' + data.rtt02 + ' TTL=' + data.ttl02 : data.responseMessage02) + '<br />' +
(data.responseStatus03 ? 'Reply from ' + elem.IP + ': bytes=32 time=' + data.rtt03 + ' TTL=' + data.ttl03 : data.responseMessage03) + '<br />' +
(data.responseStatus04 ? 'Reply from ' + elem.IP + ': bytes=32 time=' + data.rtt04 + ' TTL=' + data.ttl04 : data.responseMessage04) + '<br /><br />' +
'<b>Ping statistics for ' + elem.IP + ':</b><br />' +
indent + 'Packets: Sent = ' + data.sent + ', Received = ' + data.received + ', Lost = ' + data.lost + ' (' + data.percentLost + '% loss),<br />' +
(data.lost < 4 ? '<b>Approximate round trip times in milli-seconds:</b><br />' : '') +
(data.lost < 4 ? indent + 'Minimum= ' + data.minRtt + ', Maximum = ' + data.maxRtt + ', Average = ' + data.avgRtt : '') +
'</p>' +
'</div>';
它可以工作,但 jquery 工具提示宽度不会自动调整为最长的行。似乎行(文本)溢出了 jquery 工具提示宽度。
有任何想法吗?