'正在尝试根据对弹出窗口中显示的选项所做的选择来使用自定义数据属性值。
在下面的示例中,我有一条消息显示“我是单身,没有孩子”,点击单身时会出现一个带有选项(单身/已婚)的弹出框。如果用户点击已婚,那么我应该被替换为We are MARRIED with no kids
HTML
<div>
<span id="m-marital-status" data-single="I am" data-multiple= "We are">I am</span>
<div class="section-input">
<div class="popover-markup" id="marital-status"><a href="#" class="trigger">Single</a> with
<div class="head hide"></div>
<div class="content hide">
<ul>
<li>married</li>
<li>single</li>
</ul>
<div class="footer hide">test</div>
</div>
<span>no Kids</span>.
</div>
</div>
CSS
.popover-title {
padding: 0;
border: 0;
}
JS
$('.popover-markup>.trigger').popover({
html: true,
placement: 'top',
content: function () {
return $(this).parent().find('.content').html();
}
});