h3下的所有内容都应该是唯一的。例如,如果我们找到这个<h3>Vanderbilt Charter Academy</h3>
,我们应该删除列表中包含相同内容的任何其他li。
h3下的所有内容都应该是唯一的。例如,如果我们找到这个`
<h3>Vanderbilt Charter Academy</h3>`, we should remove any other li in the list that
contains the same thing.
<div id="cbqwpctl00_ctl24_g_a16e8b8c_a97b_4776_8dc2_f1e731034df0" class=
"cbq-layout-main">
<ul class="dfwp-column dfwp-list" style="width:100%">
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatLeft">
<h3>Vanderbilt Charter Academy</h3>
<p>Ivan Kraker<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Great Oaks Academy</h3>
<p>Ricky Fountain<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Keystone Academy</h3>
<p>Jaclyn Jeffrey<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>PreEminent Charter School</h3>
<p>Michael Stack<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Excel Charter Academy</h3>
<p>Dan Bartels<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Vanguard Charter Academy</h3>
<p>Daryl Vriesenga<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Vanderbilt Charter Academy</h3>
<p>Ivan Kraker<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Queen's Grant Community School</h3>
<p>Christy Morrin<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Knapp Charter Academy</h3>
<p>Jami Hoeksema<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Forsyth Academy</h3>
<p>Lori Hill<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Stambaugh Charter Academy</h3>
<p>Alan Harper<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Warrendale Charter Academy</h3>
<p>Brigitte Brown<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Walker Charter Academy</h3>
<p>Steve Bagley<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Cross Creek Charter Academy</h3>
<p>Joe Nieuwkoop<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Vanderbilt Charter Academy</h3>
<p>Ivan Kraker<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Walton Charter Academy</h3>
<p>John Brillhart<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Winterfield Venture Academy</h3>
<p>Amy Kramer<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Hamtramck Academy</h3>
<p>Stephanie Glenn<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Eagle Crest Charter Academy</h3>
<p>Daniel Harris<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Buffalo United Charter School</h3>
<p>Tammy Messmer<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Hamtramck Academy</h3>
<p>Stephanie Glenn<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Apex Academy</h3>
<p>Karl Boland<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Linden Charter Academy</h3>
<p>Linda Caine-Smith<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Burton Glen Charter Academy</h3>
<p>Shawn Merriweather<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Brooklyn Excelsior Charter School</h3>
<p>Thomas DeMarco<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<p>Catherine Witt<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Prevail Academy</h3>
<p>Jodi Donkin<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Paramount Charter Academy</h3>
<p>Kathleen Grinwis<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Achieve Charter Academy</h3>
<p>Claudia Williamson<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Lansing Charter Academy</h3>
<p>Chris Thompson<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<p>Paula Dowker<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Pinnacle Academy</h3>
<p>Ginny Schemrich<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>North Saginaw Charter Academy</h3>
<p>Tonya Reed<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Walker Charter Academy</h3>
<p>Steve Bagley<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<p>Paula Dowker<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<p>Paula Dowker<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Linden Charter Academy</h3>
<p>Linda Caine-Smith<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Chandler Woods Charter Academy</h3>
<p>Barbara Lindquist<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
4900 W. 15th Ave<br />
Gary, IN, 46406<br />
219-944-7400</p>
<p><a href=
"http://aspire.heritageacademies.com">http://aspire.heritageacademies.com</a><br />
<a href="mailto:email@email.com">email@email.com</a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Aspire Charter Academy</h3>
<p>Gloria McDaniel-Hall<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Chandler Woods Charter Academy</h3>
<p>Barbara Lindquist<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Linden Charter Academy</h3>
<p>Linda Caine-Smith<br />
3244 Linden Rd<br />
Flint, MI, 48504-1753<br />
810-720-0515</p>
<p><a href=
"http://linden.heritageacademies.com/">http://linden.heritageacademies.com/</a><br />
<a href="mailto:email@email.com">email@email.com</a></p>
</div>
</li>
<li class="dfwp-item">
<div class="WebPartFloatClear">
</div>
<div class="MiddleContent WebPartFloatLeft">
<h3>Chandler Woods Charter Academy</h3>
<p>Barbara Lindquist<br />
6895 Samrick Ave Private<br />
Belmont, MI, 49306-8844<br />
616-866-6000</p>
<p><a href=
"http://chandlerwoods.heritageacademies.com/">http://chandlerwoods.heritageacademies.com/</a><br />
<a href="mailto:email@email.com">email@email.com</a></p>
</div>
</li>
<li class="dfwp-item">
<div class="MiddleContent WebPartFloatRight">
<h3>Paragon Charter Academy</h3>
<p>Kathy Watson<br />
<br />
, , <br /></p>
<p><a href=""></a><br />
<a href="mailto:"></a></p>
</div>
</li>
</ul>
</div>
答案 0 :(得分:0)
我不太确定,你定义的是“同一件事”还是一切。所以我们只为它创建一个函数。
function whatISeeAsThing(node) { return node.innerHTML; }
//function whatISeeAsThing(node) { return $(node).find("h3").text(); }
//...
function removeDuplicates() {
var all = {};
$.each($(".dfwp-column li"), function (i, node) {
if (all[whatISeeAsThing(node)]) {
$(node).remove();
} else {
all[whatISeeAsThing(node)] = true;
}
});
}
答案 1 :(得分:0)
var current;
$('li').each(function() {
current = $(this);
checkDoubles(current.next());
});
function checkDoubles(oLi) {
if(current.children('h3:first').text() == oLi.children('h3:first').text()) {
checkDoubles(oLi.next());
oLi.remove();
}
checkDoubles(oLi.next());
}
像这样的东西可能会为你做到这一点
答案 2 :(得分:0)
这应该适用于你:-) http://jsfiddle.net/maniator/vA5HS/
$('.MiddleContent').each(function(){
var h3 = $(this).children('h3').text();
$(this).data('open',true)
$('.MiddleContent').each(function(){
if(($(this).data('open') == undefined || $(this).data('open') == false)){
//console.log(h3, $(this).children('h3'), this)
if(h3 == $(this).children('h3').text()){
//console.log('same');
$(this).remove();
}
}
})
$(this).data('open',false)
})
答案 3 :(得分:0)
我认为这也会奏效:
$("li.dfwp-item").each(function() {
var text = $(this).find("h3:first").text();
$("li.dfwp-item").not(this).each(function(){
if($(this).find("h3:first").text() === text){
$(this).remove();
}
});
});