Javascript jquery删除重复内容的方法
我有一个popover对话框,使用bootstrap popover填充页面底部另一个div的内容 html看起来像: 我正在循环浏览的元素,并在其中附加弹出窗口:Javascript jquery删除重复内容的方法,javascript,jquery,jquery-selectors,twitter-bootstrap,Javascript,Jquery,Jquery Selectors,Twitter Bootstrap,我有一个popover对话框,使用bootstrap popover填充页面底部另一个div的内容 html看起来像: 我正在循环浏览的元素,并在其中附加弹出窗口: <sup id="cite_ref-3-0" class="reference bootstrap-footnote" data-original-title=""> [<a href="#cite_note-3">3</a>] </sup> <li id="cite_no
<sup id="cite_ref-3-0" class="reference bootstrap-footnote" data-original-title="">
[<a href="#cite_note-3">3</a>]
</sup>
<li id="cite_note-1">
<b><a href="#cite_ref-1-0">^</a> </b>
<a target="_blank" href="http://www.guardian.co.uk/music/musicblog/2009/aug/17/major-labels-spotify/">
"Behind the music: The real reason why the major labels love Spotify"
</a>
<i>The Guardian.</i> 17 August 2009
</li>
我想我现在明白你想要什么了
$element.addClass("bootstrap-footnote").each(function(i, item) {
var liID = $('a',this).attr('href'); // this is your li's id
var footnote = $(liID).clone().find('b').remove().end(); // clone the li - remove b
$(item).popover({
html: true,
title: null,
content: footnote.html(),
delay: {
show: 50,
hide: 1500
},
//placement: "bottom",
trigger: "hover"
});
});
是 啊标记及其内部的所有内容。您不能只执行
$('b',this.remove()代码>我尝试了$('b',footnote_val).remove()代码>以相同的名称启动var后,但它什么也不做。仅供参考,我不想在复制popover时删除文档本身的标记。我用遗漏的一个步骤更新了我的问题,但除了无法删除标记外,其余代码工作正常。关闭…,奇怪的是,现在显示的唯一内容是我试图删除的内容。;-)
$element.addClass("bootstrap-footnote").each(function(i, item) {
var liID = $('a',this).attr('href'); // this is your li's id
var footnote = $(liID).clone().find('b').remove().end(); // clone the li - remove b
$(item).popover({
html: true,
title: null,
content: footnote.html(),
delay: {
show: 50,
hide: 1500
},
//placement: "bottom",
trigger: "hover"
});
});