Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在jquery中的引导popover内容中放置glyphicon_Jquery_Html_Css_Twitter Bootstrap_Glyphicons - Fatal编程技术网

如何在jquery中的引导popover内容中放置glyphicon

如何在jquery中的引导popover内容中放置glyphicon,jquery,html,css,twitter-bootstrap,glyphicons,Jquery,Html,Css,Twitter Bootstrap,Glyphicons,我想在我的popover内容旁边包含一个glyphicon,它将在jquery中动态完成。 但是当我为glyphicon添加span标记时,它会在显示popover时显示html字符串。它不会将其转换为html $(this).attr("data-content", "<span class=\"glyphicon glyphicon-warning-sign\" aria-hidden=\"true\"></span>You can't unlist if you h

我想在我的popover内容旁边包含一个glyphicon,它将在jquery中动态完成。 但是当我为glyphicon添加span标记时,它会在显示popover时显示html字符串。它不会将其转换为html

$(this).attr("data-content", "<span class=\"glyphicon glyphicon-warning-sign\" aria-hidden=\"true\"></span>You can't unlist if you have upcoming events scheduled" );
$(this.attr(“数据内容”,“如果安排了即将到来的事件,则不能取消列表”);
内容最终在popover中看起来像这样

"<span class=\"glyphicon glyphicon-warning-sign\" aria-hidden=\"true\"></span>You can't unlist if you have upcoming events scheduled"
“如果计划了即将举行的活动,则不能取消列表”

尝试在glyphicon代码周围使用单引号:

$(this).attr("data-content",'<span class="glyphicon glyphicon-warning-sign" 
aria-hidden="true"></span>You can't unlist if you have upcoming events 
scheduled');
$(this.attr(“数据内容”),如果有即将发生的事件,则不能取消列表
附表);;

根据引导文档,如果需要动态设置数据内容,则不应将其指定为属性

试试这个

HTML


爆米花示例
JS

$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({
是的,
内容:函数(){
返回(“你好”);
},
});   
});

希望这有帮助

<div class="container">
  <h3>Popover Example</h3>
  <a href="#" data-toggle="popover" title="Popover Header">Toggle popover</a>
</div>
$(document).ready(function(){
    $('[data-toggle="popover"]').popover({
    html:true,
    content:function(){
    return ("<span class='glyphicon glyphicon-user'>Hello</span>");
    },
    });   
});