Javascript jQuery:查找包含特定文本的元素

Javascript jQuery:查找包含特定文本的元素,javascript,jquery,drupal,Javascript,Jquery,Drupal,我的页面上有一个日历,下面有一个事件列表。当用户单击next(下一个)或previous(上一个)按钮时,我想用只包含日历上当前显示的月份和年份的行的内容填充一个div。下面是行的结构(使用Drupal 7视图创建) 我还应该提到,我正在使用FullCalendar创建日历,所以它是用这个插件创建的。现在,我可以获取用户正在查看的当前月份,但我希望浏览列表,找到包含此月份的所有行,并将它们显示在.event list div中。这似乎是错误的: $('#all-events').each('.v

我的页面上有一个日历,下面有一个事件列表。当用户单击next(下一个)或previous(上一个)按钮时,我想用只包含日历上当前显示的月份和年份的行的内容填充一个div。下面是行的结构(使用Drupal 7视图创建)

我还应该提到,我正在使用FullCalendar创建日历,所以它是用这个插件创建的。现在,我可以获取用户正在查看的当前月份,但我希望浏览列表,找到包含此月份的所有行,并将它们显示在.event list div中。

这似乎是错误的:

$('#all-events').each('.views-rows',function(){...});
这个怎么样:

$('.views-rows', '#all-events').each(function(){...});

我不能完全理解您想要什么,但要通过文本使用过滤元素


自1.1.4版以来,jQuery有一种选择包含特定文本的元素的方法

$('#calendar span.fc-button-next').live('click', function(){
  var month = $('#calendar .fc-header-title h2').html();
  $('.event-list').fadeOut(350, function(){
     var event_list = $(this).html('');
     $('#all-events .views-rows:contains(' + month + ')').each(function(){
       event_list.append($(this).html);
     });
     event_list.fadeIn();         
  });
});

当有多个div包含
text 1
时,它还会替换div,如下所示:
$('.views-rows', '#all-events').each(function(){...});
<div>text 1</div>
<div> not this text </div>
$("div").filter(function(){
   return $(this).text().indexOf("text 1") >= 0; // if contains desired text
}).html("this one matches 'text 1'");
$('#calendar span.fc-button-next').live('click', function(){
  var month = $('#calendar .fc-header-title h2').html();
  $('.event-list').fadeOut(350, function(){
     var event_list = $(this).html('');
     $('#all-events .views-rows:contains(' + month + ')').each(function(){
       event_list.append($(this).html);
     });
     event_list.fadeIn();         
  });
});