我正在使用Bootstrap Popver。我在弹出窗口中插入了一些数据,并且还想插入图像。这是我尝试过的。
代码:
var img = '<div id = "image"><img src = "http://news.bbcimg.co.uk/media/images/71832000/jpg/_71832498_71825880.jpg" /></div>';
var button = "<button title = " + obj.hostname + ", " + gpu.toUpperCase() +
" data-content = \"" + metric_name[metric] + ": " + display_val + img + "\"" +
" data-id=\"" + detailed_summary + "\"" +
" data-text = \"" + obj.hostname + ", " + gpu.toUpperCase() + ", " + metric_name[metric] + ": " + display_val + "\"" +
" class=\"btn " + button_state + " gpu btn-lg open-InfoModal\"" +
" data-toggle=\"modal\" " +
" data-html=\"true\" " +
" rel=\"popover\" " +
" data-target=\"#hostInfo\" " +
" href=\"#infoModal\"></button>";
初始化:
$('button').popover({
trigger: "hover",
placement: get_popover_placement,
html: true
});
我在 Stack Overflow 上看到了一些示例,但它对我不起作用,因为我想将它插入到按钮声明中。