如何将一个glyphicon放在jquery中的bootstrap popover内容中

时间:2017-07-22 20:14:04

标签: 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 have upcoming events scheduled" );

内容最终在popover

中看起来像这样
"<span class=\"glyphicon glyphicon-warning-sign\" aria-hidden=\"true\"></span>You can't unlist if you have upcoming events scheduled"

2 个答案:

答案 0 :(得分:2)

作为Per Bootstrap Docs,如果您需要动态设置<msbuild> <buildArgs>/p:Configuration=Release /p:Platform="Any CPU" /tv:14.0</buildArgs> <executable>C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe</executable> <targets>Rebuild</targets> <projectFile>mysolution.sln</projectFile> </msbuild> ,则不应将其指定为属性。

试试这个,

HTML

data-content

JS

<div class="container">
  <h3>Popover Example</h3>
  <a href="#" data-toggle="popover" title="Popover Header">Toggle popover</a>
</div>

Working Fiddle

希望这有助于......

答案 1 :(得分:-2)

尝试在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');