目的:点击一个链接/按钮,后台取出数据,popover显示取出的内容
1.设置链接:
</pre><p><pre name="code" class="html"><a id="conclusionShow" href="javascript:void(0)" onclick="showConclusion2(this)">查看结论</a>
<span style="font-size:32px;color:#3366ff;">2.设置showConclusion2方法:</span>
function showConclusion2(item){
$("#conclusionShow").popover().click(function() {
$("#content").text('YOUR CONTENT123');
});
}
3.初始化
$(function() {
$("[data-toggle='popover']").popover();
});
$(document).ready(function () {
$("#conclusionShow").popover({
html: true,
content: '<div id="content"></div>'
});
});
4. 实现popover内文件换行
按照上面的步骤做完,其实content取的值是div的内容,而上面设置了popover支持html,如果可以将content改成为:
$(item).popover({html: true}).click(function() {
$("#content").html(conclusion);
});
conclusion的内容为: 测试一下<br> 换个行再来一次
即可实现popover内容换行