我有这个,但它似乎没有做任何事情,但我无法弄清楚为什么......语法似乎很好。
$('#entries li').not(function() {
return $('span.date:contains("March 2016")', this);
}).hide();
在我使用的另一个功能中:
$('#entries li').not(function() {
return $('.date', this).text() === formattedDate;
}).hide();
那个工作正常。
非常感谢任何帮助。
答案 0 :(得分:3)
$('#entries li')
这个与
$('#entries li').not(function() {
return $('span.date:contains("March 2016")', this);
}).hide();
因为您一直在回调中返回一个真值。您必须在此上下文中使用.is()
函数来完成任务。
$('#entries li').not(function() {
return $('span.date', this).is(':contains("March 2016")');
}).hide();
或者简单地说,
$('#entries li span.date:contains("March 2016")').hide();